home *** CD-ROM | disk | FTP | other *** search
- ;*---------------------------------------------------------------------------
- ; :Program. osemu.asm
- ; :Author. Harry, Wepl
- ; :RCS. $Id: osemu.asm 1.1 1999/02/03 04:10:48 jotd Exp jotd $
- ; :History. all work before history starts done by Harry
- ; 30.06.98 Wepl rework started
- ; 06.07.98 Wepl rework finished
- ; 07.07.98 Wepl exec.Supervisor,exec.SuperState,exec.UserState
- ; exec.FindTask,exec.FindPort,exec.OpenDevice
- ; graphics.alot,exec.DoIO
- ; 15.07.98 Wepl work for Deuteros finished
- ; 31.07.1998 Harry SSP set on memtop again as it is in kick1.3
- ; possibility of trainer routine added
- ; 10.08.98 Wepl osemu header struct changed (SLAVETRAINER now
- ; in osemu-struct instead overgiven via reg)
- ; 10.08.98 Wepl gfx.BltBitMap fixed
- ; ??.08.98 MrLarmer some additions
- ; 05.09.98 Wepl AddIntServer/RemIntServer finally fixed
- ; ReadPixel,WritePixel added
- ; 06.09.98 Wepl return values after init changed (bootblock)
- ; BltTemplate started (but unfinished)
- ; 22.09.98 Wepl _SendIO is now the same as _DoIO (fix for Deuteros)
- ; 27.09.98 Harry dos.lock (untested), device-names even-
- ; aligned (68000-prob), (usp) initialized
- ; with stacksize (CC3 expects it in 4(usp) at
- ; start), dummy: dos.input+dos.output+
- ; exec.waitport
- ; 29.09.1998 Harry list management functions implemented:
- ; exec.insert, exec.(add|rem)(head|tail), exec.remove
- ; 07.10.1998 Harry list handling debugged, libs as list, one process
- ; structure, exec.findtask changed, _initlibary
- ; splittet, exec.getmsg, dos.deviceproc, intuition.
- ; openwindow, intuition.closewindow, icon.library,
- ; intuition.cleardmrequest, dos.unloadseg,
- ; minor fixes
- ; 11.10.1998 Harry devices as list, dos.loadseg supports hunk_symbol,
- ; audio.device-dummy, gfx.allocraster, gfx.freeraster,
- ; gfx.bltclear, gfx.initbitmap (and #fe), intuition.
- ; lockibase dummy, layers.library, mathffp.library,
- ; trackdisk.device-msgport, execlib-table implemented
- ; directly, exec.copymem, exec.findname, minor fixes
- ; 19.10.1998 Harry dos.examine, dos.unlock, exec.setintvector,
- ; audio-interrupts, gfx.getcolormap
- ; 20.10.1998 Harry gfx.set(a|b)pen, gfx.setdrmd, gfx.initrastport,
- ; topaz.font-replacement, gfx.openfont, gfx.setfont,
- ; some gfx-structures
- ; 24.10.1998 Harry gfx.text, some debugging, exec.allocsignal,
- ; gfx.move, problem with input.addhandler,
- ; exec.availmem keeps now a reserve of $1000,
- ; gfx.freecolormap
- ; 31.10.98 Wepl input.device fixed, color handling changed
- ; (getcolormap,freecolormap,loadrgb4,initview,
- ; initvport,makevport,loadview,setrgb4,getsprite,
- ; freesprite,movesprite,changesprite,vbi
- ; 03.11.1998 Wepl bug in AllocMem fixed (size rounded up now)
- ; 25.11.1998 Harry switched back to old gfx-viewport-stuff,
- ; gfx.loadview(0)
- ; 30.11.1998 MrLarmer exec.(create|delete)(iorequest|msgport),
- ; exec.freesignal, exec.allocsignal changed
- ; 01.12.1998 Harry libs in osemu extended to V40 (as i dont have
- ; 3.1-includes working with asm-one do not have
- ; the idea to replace the values by labels,
- ; ill change them back!), exec.exitintr
- ; 05.12.1998 Harry some debugging, list handling debugged again,
- ; exec.allocmem:MEMF_LARGEST dummy, MEMF_REVERSE
- ; dummy, exec.setsignal, dos.currentdir,
- ; dos.waitforchar, execbase.vblankfrequency,
- ; dos.duplock
- ; 09.01.1999 JOTD bugfix in DoIO() return code (D0). "implemented"
- ; CMD_UPDATE (does nothing) and CMD_CLEAR
- ; 09.01.1999 JOTD improved CloseWorkbench() intuition call
- ; Now returns 0 only once, and then 1
- ; Led Storm does not lock anymore now
- ; 10.01.1999 JOTD added AlohaWorkbench() intuition call (dummy)
- ; added WaitBOFVP() (not accurate)
- ; added CloseScreen() (dummy)
- ; 14.01.1999 JOTD added dos.library Info() function
- ; (for Flashback)
- ; 15.01.1999 JOTD added D0=0 return codes in input.device
- ; 15.01.1999 JOTD added lowlevel.library, nonvolatile.library
- ; added cd.device and freeanim.library (dummies)
- ; added exec CheckIO
- ; improved DoIO (dummy support of cd.device,cdtv.device)
- ; added WaitIO (dummy support of cd.device,cdtv.device)
- ; added SetFunction (for Banshee, now intro OK)
- ; 30.01.1999 JOTD added keyboard.device (not complete)
- ; installed a default empty copperlist to avoid problems
- ; with JST
- ; 02.02.1999 JOTD added complete lowlevel.library ReadJoyPort() function
- ; using function keys (F1-F5) for joypad extra buttons
- ; DoIO/SendIO: if device is not found, then return with
- ; no error (dummy for cd.device)
- ; Oscar CD32 now works perfectly!
- ; 18.03.1999 MrLarmer keyboard.device improved
- ; FreeSignal improved
- ;
- ; 30.03.1999 JOTD Added graphics.library InitTmpRas, InitArea
- ; 01.04.1999 JOTD Added mathffp.library SPFlt,SPDiv (removed
- ; from intuition.s)
- ; 01.04.1999 JOTD Added mathtrans.library SPATan (untested)
- ; 17.04.1999 JOTD Dummy console.device added
- ; 19.05.1999 JOTD Added CMD_WRITE to trackdisk DoIO (for ArcadePool)
- ; Added dummy entry for nonvolatile StoreEnv
- ; Added items in the OSEmu structure for use with JST
- ; Added OSEmu ID, version/release and version string
- ; Added whdmacros.i include for v10 WHDLoad .i files
- ; 26.05.1999 JOTD Added EntryType to FileInfoBlock structure
- ; (Sensible Soccer CD32 v1.2 needed 2 $FFFF in struct
- ; to get hold of the filesize, the bastards!)
- ; 08.06.1999 JOTD Added fastmemory support, debug entry (HRTMon)
- ; Added flush cache after LoadSeg() succeeded (v1.4)
- ; 11.06.1999 JOTD Corrected LoadSeg() to allocate hunks in chip/fast (v1.5)
- ; 26.06.1999 JOTD Added dummy AssignPath()
- ; Added disk.resource OpenResource() (no functions yet)
- ; Fixed a bug in Examine if not found (FreeMem problem)
- ; Added ExamineFH (SlamTilt)
- ; Added AllocRemember/FreeRemember (SlamTilt)
- ; 10.08.1999 JOTD Added dummy disk.resource GetUnit()
- ; Added AllocEntry/FreeEntry (on Bored Seal request) (v1.7)
- ; 24.09.1999 JOTD Bugfixed DupLock() (v1.8)
- ; 12.02.2000 JOTD Added dummy RemakeDisplay for Darkmere (v1.9)
- ; LoadSeg() bugfix: zero-length hunks are allowed
- ; 21.02.2000 Harry Copperinterrupt implemented, Audioint and
- ; Add/RemIcrVector fixed, minor changes (v1.10)
- ; Added HUNK_DEBUG support to LoadSeg()
- ; 02.03.2000 JOTD Added dummy IoErr() (v1.11)
- ; 12.04.2000 JOTD Improved IoErr() (v1.12)
- ; Added dos.library ExNext() (don't know if it works well)
- ; Changed dos.library Examine() for Volumes. Maybe I shouldn't have.
- ; Added exec.library TypeOfMem() for Subwars 2050
- ; Added dummy keymap.library, diskfont.library, utility.library
- ; 14.04.2000 JOTD Thanks to Harry, fixed gfx library copper stuff: OSEmu is much
- ; smaller now, and inserted a define to disabled math libs,
- ; rather unused (v1.13)
- ; 18.05.2000 JOTD Rewritten UCopListInit (untested)
- ; Added start of Examine/ExNext, a bit buggy, so ExNext disabled
- ; Added a valid Taskwait in exec structure
- ; Added intuition's OpenScreen
- ; Added intuition's MakeScreen
- ; Added lame dos DateStamp
- ; Added dos CreateProc
- ; Added dummy timer.device (in work)
- ; Added OpenFromLock (easy as Lock & FH struct are the same for OSEmu)
- ; Added exec's AllocVec, FreeVec
- ; Changed version strings (v1.14)
- ; 05.06.2000 JOTD Big completions done on Process structure and Dos Library structure
- ; Now it is possible to simulate autodetachable code (Delphine programs)
- ; Added dummy GetDiskObject
- ; Added lowlevel.library AddTimerInt, and cia's AbleICR
- ; but does not work yet (and was a dirty resource of ROMs :) ) (v1.15)
- ; 10.06.2000 JOTD Added buffered file write (DOSSAVE) (v1.16)
- ; DosLock & DosFileHandle structure code cleanup for
- ; future BCPL conversion and real structure offsets
- ; 07.09.2000 JOTD Fixed _strcmp bug which impacted on FindName()
- ; Changed source to compile with WHDLoad v12 include (patch) (v1.17)
- ; 13.09.2000 JOTD Added StackSwap (direct 3.1 ROM resource) (v1.18)
- ; 24.09.2000 JOTD Better fake dos.Output() implementation
- ; Set iv_Data #$D to GfxBase in ExecBase
- ; (games expect this to restore clist)
- ; Improved SetIntVector (direct (almost!) 3.1 ROM resource)
- ; Added Blitter interrupt support for AddIntServer/SetIntVector
- ; Now miracle: Banshee graphics & sound work OK !!!
- ; Fixed AddIntServer: now activates the required interrupt (v1.19)
- ; 29.09.2000 JOTD Fixed intuition.AllocRemember and FreeRemember
- ; Now SlamTilt works 100% (v1.20)
- ; 30.09.2000 JOTD CLI.CommandName updated on a dos.LoadSeg
- ; dos.Open, dos.Close, dos.Lock, etc... use BCPL pointers
- ; (some games like to read in the filehandler structure...)
- ; Added utility.library support for 68020+ only (multiply
- ; and divide functions)
- ; Added diskfont.library OpenDiskFont() (calls OpenFont()
- ; with topaz8, what a shame).
- ; Added graphics.library lame TextLength()
- ; Improved exec.Enable and exec.Disable (nest count support) (v1.21)
- ; 02.10.2000 JOTD Bugfix in BCPL pointer handling
- ; ExNext implemented. Now directory scanning works
- ; Improved intuition.library opening sequence, a default screen
- ; now opens
- ; dos.LoadSeg() now also returns seglist in D1
- ; intuition.OpenScreen() improved
- ; graphics.GetRGB4() implemented. still in test (v1.22)
- ; 15.10.2000 JOTD intuition.OpenScreenTagList() implemented (Pinball Illusions)
- ; SetIntVector now accepts copper interrupts (Frontier)
- ; Fixed CLI.CommandName value (Frontier)
- ; Added intuition.ViewAddress()
- ; Added dummy dos.IsInteractive() (returns FALSE)
- ; Added dummy intuition.SetPointer()
- ; Removed some copperlist diwstrt, diwstop I introduced
- ; some time ago for Banshee
- ; Added dos.DeleteFile() for Frontier
- ; Totally rewrote volume/directory management in dos.s
- ; (the cmp #':' test was not enough) (v1.23)
- ; 16.10.2000 JOTD Added CurrentDir support, now Guardian works!
- ; Added dummy locale.OpenLocale, Fighting Spirit works
- ; Added exec.CopyMemQuick
- ; Fixed a LoadSeg() bug I introduced in v1.23 (v1.24)
- ; 20.10.2000 JOTD Added AllocBitMap (direct OS3.1 resource)
- ; dos.LoadSeg() now supports overlays!
- ; more permissive AllocMem (D1 now allows trash, cf Test Drive II)
- ; Debugged AllocVec/FreeVec (it did not work at all!)
- ; LoadSeg() now makes WHDLoad/JST fail if problems with structure
- ; Fixed exec.FreeEntry
- ; Added intuition.ViewPortAddress() (Lost Vikings)
- ; Added disk.resource.GiveUnit() (dummy!) (v1.25)
- ; 31.10.2000 JOTD Added some mathffp.library calls
- ; Added exec.GetCC()
- ; Improved intuition initialization
- ; Fixed OpenWindow. Killerball now works (v1.26)
- ; 02.11.2000 JOTD Protected CurrentDir against file locks
- ; Fixed DupLock/OpenFromLock for root lock
- ; Bugfixed OpenScreen (my fault!)
- ; Added partial timer.device support (UNIT_VBLANK,UNIT_MICROHZ)
- ; Fake ReadEClock added, GETSYSTIME request added
- ; Fixed intuition.GetCurrentTime
- ; Added intuition.PubScreenStatus
- ; Added graphics.BestModeIDA
- ; Added font pointer in most intuition/graphics structures
- ; Added ciax.SetICR (Wings,lowlevel.library)
- ; Added lowlevel.StartTimerInt
- ; Added dummy nonvolatile.GetNVInfo
- ; Added lowlevel.QueryKeys
- ; Enlarged KeyboardMatrix data (could be out of bounds!)
- ; Allowed cd.device open again. Maybe trouble with Robocod CD32...
- ; Adjusted timers reload values, Fire&Ice CD sounds good (V1.27)
- ; 07.11.2000 Harry Added RemTimerInt, SetICR, debugged lowlevel-
- ; TimerInt-stuff, debugged cia.resource
- ; 11.11.2000 JOTD Fixed CLI structure stack size (now in longwords)
- ; Added dma sprite enable on intuition open
- ; Protected FreeMem() against $bbbbbbbb address (Wings, temporary)
- ; Completed InitRastPort initialization (Test Drive II)
- ; Added partial RawDoFmt support
- ; Debugged OpenWindow/OpenScreen/active window/screen stuff
- ; Improved lowlevel.ReadJoyPort. Now handles multiple keypresses
- ; Changed joypad emulation keys: now F5 to F10
- ; Fixed second joystick button emulation (CD32 games)
- ; Finished to merge Harry's changes. Adjusted CIA timer rate (v1.28)
- ; 12.11.2000 JOTD Added timer.ReadEClock and lowlevel.ElapsedTime,
- ; now Zool CD32 works (v1.29)
- ; 13.11.2000 Harry Made Joypad-emulationkeys configurable, debugged
- ; lowlevel.library even more
- ; 17.11.2000 JOTD Added console.RawKeyConvert (v1.30)
- ; 20.11.2000 Harry Bugfixed intuition initialization and GetPrefs, added
- ; graphics.BltMaskBitMapRastPort, fixed lowlevel.ReadJoyPort (v1.31)
- ; 22.11.2000 JOTD Added exec.Cause (approximative, but works with Darkseed)
- ; Added intuition.UnlockIbase (dummy) (v1.32)
- ; 27.11.2000 JOTD Ooops, fixed bug introduced some time ago: some games had
- ; no display (KQ6, Beneath a Steel Sky, Deuteros, and possibly others)
- ; Added dummy misc.resource (CAP) (v1.33)
- ; 01.12.2000 JOTD Restored sprites in Deuteros/Millenium
- ; Ooops, merged both SetICR versions (mine & Harry) because
- ; of music slowness bug came back, sorry Harry! (v1.34)
- ; 15.12.2000 JOTD graphics.ClipBlit added (Ports of Call)
- ; Fixed intuition.CloseWindow, now frees RastPort
- ; Improved intuition.OpenWindow
- ; Re-enabled Enqueue, added AddPort, RemPort, FindPort
- ; Added GetMsg, partial implementations of PutMsg & ReplyMsg
- ; Fixed graphics.UCopperListInit, rewritten graphics.MakeVPort
- ; Better graphics.MrgCop, can merge sprites/display/user clists
- ; Changed exec.FindName (some optimizers could lose Z flag)
- ; Implemented intuition.RethinkDisplay (Monkey Island)
- ; Replaced Add/Rem/Head/Tail+Remove by official exec macros
- ; (with register protection, as OSEmu uses them internally)
- ; Added intuition input handler to handle IDCMP events
- ; Bugfixed ss_num access in gfxlib sprite handling routines
- ; Better gfxlib sprite init: no more sprite glitches
- ; Did some hacks for Speris Legacy (intuition handler, sprites)
- ; Improved GetPrefs, now reads l/system-configuration if called
- ; Changed IND_ADDHANDLER in DoIo() for input.device
- ; Now Secret Of Monkey Island runs (still mouse problems)
- ; Added keyboard acknowledge at exec startup
- ; Restored old Harry's dos.Write code because bufferized one
- ; does not seem to work (v1.35)
- ; 22.12.2000 JOTD fake egs.library open failure added (Tower Assault)
- ; Bugfixed graphics.FreeVPortCopLists (v1.36)
- ; 01.01.2001 JOTD Ooops, incompatibility in old dos.Write routine, now fixed
- ; (v1.37)
- ; 06.01.2001 JOTD Another regression fixed: Arcade Pool display was black.
- ; Ooops, another bug left in the old write routine, Damn!
- ; (v1.38)
- ; 10.01.2001 JOTD Added dos.SetIoErr, dos.CheckSignal (dummy),
- ; Improved dos.IsInteractive
- ; 28.01.2001 JOTD Changed intuition pointer management. Now only appears
- ; if SetPointer is called (v1.39)
- ; 30.01.2001 JOTD Return value changed in graphics.Text (old expected value, LCP)
- ; 01.02.2001 JOTD exec.AddTask first implementation try (not connected yet!!)
- ; added real exec.Forbid
- ; exec.Permit, private exec.Dispatch, exec.Switch, exec.Reschedule
- ; Slightly improved exec.CacheControl
- ; exec.AllocMem/FreeMem now task switching proof
- ; 17.02.2001 JOTD Fixed 2nd joystick button problems with non-lowlevel lib games
- ; All DOS functions existing in kick 1.x also return result in D1
- ; (old BCPL expected behavior)
- ; Changed exec task type from NT_TASK to NT_PROCESS (more accurate)
- ; Duplicated fib_DirEntryType value in fib_EntryType, and changed
- ; directory type value. Also fixed protection flags (were inverted)
- ; Removed dirty direct ALLOCM/FREEM calls from other libs than exec
- ; Implemented real intuition.SetPrefs (v1.40)
- ; 22.02.2001 JOTD dos.Open() always returned a filehandle even if file not found. Fixed
- ; Added error codes for dos.Open and dos.Lock
- ; exec.AllocMem fixed (no more fast -> try chip)
- ; Fixed intuition mouse event handling.
- ; Monkey Island finally works !! (v1.41)
- ; 23.02.2001 JOTD Improved graphics.RastPort structure (added dummy Layer info)
- ; Fixed graphics.MakeVPort (Maniac Mansion)
- ; GetPrefs also looks in rootdir for system-configuration
- ; Fixed graphics.InitView (completely broken!)
- ; Renamed many dos,intuition,exec entrypoints for better
- ; coherence. Removed specific JST flags (were useless) (v1.42)
- ; 01.03.2001 Harry Added real support for nonvolatile library (v1.43)
- ; 08.03.2001 JOTD exec.AllocMem now avoid clearing memory if MEMB_CLEAR is unset
- ; (faster initialization)
- ; improved lowlevel.library keyboard interrupt routine
- ; dos.ParentDir added
- ; intuition.OpenScreenTagList fixed (v1.44)
- ; 08.03.2001 JOTD Fixes due to non cleared memory allocation
- ; nonvolatile.GetNVList added (todo!)
- ;
- ; Note: - does not run with JumpingJackSon slave because
- ; it expects an old bug in dos.LoadSeg (APTR instead BPTR)
- ;
- ; :Copyright. GPL
- ; :Language. 68000/68020 Assembler
- ; :Translator. Asm-One V1.30 R399, Barfly V2.9, Asm-Pro V1.12, Devpac V3.14
- ;---------------------------------------------------------------------------*
- ; Currently emulated functions:
- ; exec.library
- ; _LVOAddHead
- ; _LVOAddIntServer
- ; _LVOAddPort
- ; _LVOAddTail
- ; _LVOAllocAbs
- ; _LVOAllocMem
- ; _LVOAllocSignal
- ; _LVOAvailMem
- ; _LVOCloseDevice ;dummy
- ; _LVOCloseLibrary ;dummy
- ; _LVOCopyMem ;not optimized
- ; _LVODisable
- ; _LVODoIO ;some of trackdisk/input/keyboard
- ; _LVOEnable
- ; _LVOExitIntr ;experimentally
- ; _LVOFindName
- ; _LVOFindTask ;partially
- ; _LVOForbid
- ; _LVOFreeMem
- ; _LVOGetMsg
- ; _LVOInsert
- ; _LVOOldOpenLibrary
- ; _LVOOpenDevice ;only trackdisk/input/keyboard/timer/console !
- ; _LVOOpenLibrary
- ; _LVOOpenResource
- ; _LVOPermit ;dummy
- ; _LVORemove
- ; _LVORemHead
- ; _LVORemIntServer
- ; _LVORemPort
- ; _LVORemTail
- ; _LVOSendIO
- ; _LVOSetIntVector ;exact v40, only audiointerrupts & blitter (but can be easily extended)
- ; _LVOSetSignal
- ; _LVOStackSwap ;exact v40
- ; _LVOSuperState ;exact v39
- ; _LVOSupervisor
- ; _LVOUserState ;exact v39
- ; dos.library
- ; _LVOClose
- ; _LVOCurrentDir ;returns always 0 for rootdir
- ; _LVODeviceProc ;dummy
- ; _LVOCreateProc ;of course no multitasking, but starts child
- ; _LVODupLock ;limited to files and null for rootdir
- ; _LVOExamine ;doesnt work for dirs atm, only files and volumes
- ; _LVOInput ;dummy
- ; _LVOLoadSeg ;can take advantage of fast memory if expansion on
- ; _LVOLock ;atm no dirs, only files and volumes
- ; _LVOOpen
- ; _LVOOutput ;dummy
- ; _LVORead
- ; _LVOSeek
- ; _LVOUnLoadSeg
- ; _LVOUnLock ;internal the same as dos.close
- ; _LVOWaitForChar
- ; _LVOWrite
- ; graphics.library
- ; _LVOAllocRaster
- ; _LVOBltBitMap ;has still some limitations !
- ; _LVOBltClear ;with CPU
- ; _LVOBltTemplate ;broken
- ; _LVODisownBlitter ;dummy
- ; _LVOChangeSprite
- ; _LVODraw ;dummy !
- ; _LVOFreeColorMap
- ; _LVOFreeRaster
- ; _LVOFreeSprite
- ; _LVOGetColorMap
- ; _LVOGetSprite
- ; _LVOInitBitMap
- ; _LVOInitRastPort
- ; _LVOInitView ;dummy !
- ; _LVOInitVPort ;dummy !
- ; _LVOLoadView ;sets copperlist
- ; _LVOLoadRGB4 ;sets colors immediate
- ; _LVOMakeVPort ;builds copperlist
- ; _LVOMove
- ; _LVOMoveSprite
- ; _LVOMrgCop
- ; _LVOOwnBlitter ;dummy
- ; _LVOReadPixel
- ; _LVOSetAPen
- ; _LVOSetBPen
- ; _LVOSetDrMd
- ; _LVOSetRGB4 ;sets color immediate
- ; _LVOUCopperListInit ; untested
- ; _LVOCMove
- ; _LVOCWait
- ; _LVOCBump
- ; _LVOText
- ; _LVOVBeamPos
- ; _LVOWaitBlit
- ; _LVOWaitTOF
- ; _LVOWritePixel
- ; intuition.library
- ; _LVOClearDMRequest ;dummy
- ; _LVOCloseWindow
- ; _LVOCloseWorkbench
- ; _LVOOpenWindow
- ; _LVOOpenScreen
- ; _LVOSetPointer
- ; _LVOClearPointer
- ; _LVORethinkDisplay
- ; ciaa.resource,ciab.resource
- ; _LVOAddICRVector
- ; _LVOAbleICR ; untested, direct ROM rip (JOTD)
- ; _LVORemICRVector
- ; icon.library
- ; layers.library
- ; mathffp.library
- ; mathtrans.library
- ;---------------------------------------------------------------------------*
- ; programs using or able to use this stuff (non exhaustive list):
- ; AnotherWorld (WHDLoad), Arcade Pool (JST), Blue Angel 69 (WHDLoad),
- ; Bombuzal (WHDLoad), Bubble Bobble (JST), Castle Master (WHDLoad),
- ; Colorado, Crazy Cars 3 (WHDLoad), Deuteros (WHDLoad), Flashback (JST),
- ; Flink CD32 (WHDLoad), JumpingJackSon (WHDLoad), Lionheart (WHDLoad),
- ; Metal Mutant, North&South (WHDLoad), Oscar CD32 (JST),
- ; PushOver (WHDLoad), Sensible Soccer CD32 (JST), Zynaps (JST),
- ; Lemmings Holiday 94, Slayer (WHDLoad), 1943, Street Fighter II Turbo CD32
- ; Shadow Fighter CD32 (JST), Son Of Stag series (JST),
- ; Street Fighter 1 (JST), Bubba and Stix (JST), Sierra Soccer (JST),
- ; Clockwiser (JST), Morph CD32 (JST), Impossible Mission 2025 (JST),
- ; Heimdall 2 AGA (JST), Soldier Of Light (WHDLoad), Cruise For A Corpse,
- ; Operation Stealth (JST), Arcade Snooker (JST), Dune (JST), Heimdall 2 AGA (JST),
- ; Tower Of Souls (JST), Panza Kick Boxing (WHDLoad), Legacy Of Sorasil (JST),
- ; Super Obliteration (WHDLoad), Banshee (JST), Full Metal Planete (JST),
- ; Zool 2 (JST), SlamTilt (JST), Bomb'X (JST), Frontier (JST), Robocod CD32,
- ; MadTV, Fighting Spirit (JST), Guardian, Lost Vikings (JST), NightShift (JST),
- ; Settlers (JST), Alien Breed SE CD32 (JST), Fire & Ice CD32 (JST),
- ; Chaos Engine 2 (JST/WHDLoad), Zool CD32 (JST), Secret Of Monkey Island (JST),
- ; Led Storm (JST)
- ;
- ; unfinished:
- ; Millenium 2·2, Lords of War (works until title),
- ; Prehistorik (gfx.MrgCop must be improved),
- ; Black Tiger (JST) (works until title)
- ; Imperium (access fault), Wings (problems with overlay)
- ;---------------------------------------------------------------------------*
- ; ToDo:
- ; rewriting memory management for less memory waste
- ; implement dos.waitforchar fully: allow open to raw:, read characters,
- ; close
- ; support nonexisting files in dos.lib
- ;---------------------------------------------------------------------------*
- ; How to use in WHDLoad:
- ;
- ; ;load the osemu module
- ; lea (_osemu,pc),a0 ;filename of the osemu module
- ; lea ($400.w),a1 ;the address on which you have
- ; ;assembled the osemu module
- ; move.l (_resload,pc),a2 ;the resload base
- ; jsr (resload_LoadFileDecrunch,a2) ;this allows to
- ; ;compress the osemu
- ; ;init the osemu module
- ; ;system stack has to be on
- ; ;top of memory (automatically
- ; ;done by whdload)
- ; move.l (_resload,pc),a0 ;the resload base
- ; lea (_base,pc),a1 ;the slave structure
- ; jsr $400
- ;
- ; ;start the program
- ; move #0,sr ;if the program uses the os it
- ; ;should executed in user mode
- ;
- ; ;if you want to add a trainer use this, to setup a routine which will
- ; ;be called each time a key is pressed (d0.b contains rawkeycode)
- ; lea (_trainer,pc),a0
- ; move.l a0,($404.w)
- ; ;if you want to use fast memory:
- ; lea (_base,pc),a1 ;the slave structure
- ; move.l (ws_ExpMem,A1),($424.w)
- ; move.l #<expmem size>,($428.w)
- ;
- ;---------------------------------------------------------------------------*
-
- ;---------------------------------------------------------------------------*
- ; How to use in JST:
- ;
- ; ;allocate expansion memory if needed
- ;
- ; move.l #$100000,D0 ; 1meg
- ; JSRABS AllocExtMem
- ;
- ; ;load the osemu module (when the OS is active)
- ;
- ; JSRABS UseHarryOSEmu
- ;
- ; ;start the program
- ;
- ; GO_SUPERVISOR
- ; SAVE_OSDATA xxxx ; classical OS-kill call
- ;
- ; move #0,sr ;if the program uses the os it
- ; ;should executed in user mode
- ; ;but it's seldom necessary
- ;
- ; ;if you want to add a trainer use this, to setup a routine which will
- ; ;be called each time a key is pressed (d0.b contains rawkeycode)
- ; lea (_trainer,pc),a0
- ; move.l a0,$400+OSM_SLVTRAINER
- ;
- ; Anyway, you should use the InstallWizard to create JST install template
- ; OSEmu is fully supported by InstallWizard
- ;
- ;---------------------------------------------------------------------------*
-
- INCLUDE whoami.i ;this contains only a symbol
-
- IFD HARRY ;(asm-one)
- INCDIR ASM-ONE:INCLUDE2.0/
- INCLUDE LIBRARIES/DOS_LIB.I
- INCLUDE LIBRARIES/DISKFONT_LIB.I
- INCLUDE LIBRARIES/DOS.I
- INCLUDE DEVICES/INPUT.I
- INCLUDE DEVICES/KEYBOARD.I
- INCLUDE DEVICES/TRACKDISK.I
- INCLUDE DOS/DOSEXTENS.I
- INCLUDE DOS/DOSHUNKS.i
- INCLUDE RESOURCES/CIA_LIB.I
- INCLUDE UTILITY/UTILITY_LIB.I
- INCLUDE EXEC/EXEC_LIB.I
- INCLUDE EXEC/LISTS.I
- INCLUDE EXEC/MEMORY.I
- INCLUDE EXEC/TASKS.I
- INCLUDE GRAPHICS/GRAPHICS_LIB.I
- INCLUDE GRAPHICS/LAYERS_LIB.I
- INCLUDE GRAPHICS/GFXBASE.I
- INCLUDE GRAPHICS/DISPLAYINFO.I
- INCLUDE GRAPHICS/SPRITE.I
- INCLUDE HARDWARE/CUSTOM.I
- INCLUDE INTUITION/INTUITION_LIB.I
- INCLUDE INTUITION/INTUITION.I
- INCLUDE INTUITION/PREFERENCES.I
- INCLUDE MATH/MATHFFP_LIB.I
- INCLUDE MATH/MATHTRANS_LIB.I
- INCLUDE OWN/CCRMAKRO
- INCLUDE OWN/WHDLOAD.I
- INCLUDE WORKBENCH/ICON_LIB.I
- INCLUDE OWN/WHDMACROS.I
- INCLUDE OWN/LOWLEVEL_LIB.I
- INCLUDE OWN/LOWLEVEL.I
- INCLUDE OWN/NONVOLATILE_LIB.I
- INCLUDE RESOURCES/DISK_LIB.I
- INCLUDE LIBRARIES/LOCALE_LIB.I
- INCLUDE DEVICES/TIMER_LIB.I
-
- HUNKB_CHIP = 30
- HUNKB_FAST = 31
- INCDIR ASM-ONE:OWN/PATCHER/OSEMUnew/
-
- JSRLIB MACRO
- JSR _LVO\1(a6)
- ENDM
- JMPLIB MACRO
- JMP _LVO\1(a6)
- ENDM
- org $400
- load $100000
- ENDC
- IFD WEPL ;(barfly)
- INCDIR Includes:
- INCLUDE devices/input.i
- INCLUDE devices/inputevent.i
- INCLUDE devices/trackdisk.i
- INCLUDE devices/keyboard.I
- INCLUDE dos/dos.i
- INCLUDE dos/doshunks.i
- INCLUDE dos/dosextens.i
- INCLUDE exec/memory.i
- INCLUDE exec/tasks.i
- INCLUDE exec/lists.i
- INCLUDE graphics/gfx.i
- INCLUDE graphics/gfxbase.i
- INCLUDE graphics/rastport.i
- INCLUDE graphics/sprite.i
- INCLUDE graphics/view.i
- INCLUDE intuition/intuition.i
- INCLUDE intuition/preferences.i
- INCLUDE lvo/cia.i
- INCLUDE lvo/dos.i
- INCLUDE lvo/exec.i
- INCLUDE lvo/graphics.i
- INCLUDE lvo/icon.i
- INCLUDE lvo/intuition.i
- INCLUDE lvo/layers.i
- INCLUDE lvo/mathffp.i
- INCLUDE lvo/mathtrans.i
- INCLUDE whdload.i
- INCLUDE whdmacros.i ; added for WHDLoad v10 includes
-
- IFD BARFLY
- BOPT O+ OG+ ;enable optimizing
- BOPT ODd- ODe- ;disable mul optimizing
- BOPT w4- ;disable 64k warnings
- SUPER ;disable supervisor warnings
- ENDC
-
- ORG $400
- OUTPUT OSEmu.400
- ;OUTPUT wart:a/anotherworld/osemumodule400.bin
- ;OUTPUT wart:b/bombuzal/osemumodule400.bin
- ;OUTPUT wart:d-f/deuteros/OSEmu.400
- ;OUTPUT wart:h-j/jumpingjackson/osemumodule400.bin
- ;OUTPUT wart:m/millennium2·2/OSEmu.400
- ;OUTPUT wart:n-p/north&south/OSEmu.400
- ENDC
-
- IFD JOTD ;(phxass/barfly)
- INCDIR include:
- INCLUDE "LVOs.i"
- INCLUDE "jst_libs.i"
- INCLUDE "dos/doshunks.i"
- INCLUDE "devices/trackdisk.i"
- INCLUDE "devices/input.i"
- INCLUDE "exec/io.i"
- INCLUDE "devices/keyboard.I"
- INCLUDE "devices/timer.i"
- INCLUDE "devices/inputevent.i"
- INCLUDE "exec/interrupts.i"
- INCLUDE "exec/ports.i"
- INCLUDE "exec/lists.i"
- INCLUDE "graphics/gfx.i"
- INCLUDE "graphics/gfxbase.i"
- INCLUDE "graphics/rastport.i"
- INCLUDE "graphics/copper.i"
- INCLUDE "graphics/sprite.i"
- INCLUDE "graphics/view.i"
- INCLUDE "intuition/intuition.i"
- INCLUDE "intuition/preferences.i"
- INCLUDE "intuition/screens.i"
- INCLUDE "libraries/lowlevel.i"
- INCLUDE "utility/utility.i"
- INCLUDE "libraries/nonvolatile.i"
-
- INCLUDE "whdload.i"
- INCLUDE "whdmacros.i" ; added for WHDLoad v10 includes
-
- IFD BARFLY
- BOPT O+ OG+ ;enable optimizing
- BOPT ODd- ODe- ;disable mul optimizing
- BOPT w4- ;disable 64k warnings
- BOPT wo- ;disable optimizer warnings
- SUPER ;disable supervisor warnings
- ENDC
-
- ORG $400
- OUTPUT C:OSEmu.400
-
- ENDC
-
- IFD MR.LARMER ;(devpac)
- INCDIR Include:
- INCLUDE devices/input.i
- INCLUDE devices/inputevent.i
- INCLUDE devices/keyboard.i
- INCLUDE devices/trackdisk.i
- INCLUDE dos/dos.i
- INCLUDE dos/doshunks.i
- INCLUDE dos/dosextens.i
- INCLUDE exec/memory.i
- INCLUDE graphics/gfx.i
- INCLUDE graphics/gfxbase.i
- INCLUDE graphics/rastport.i
- INCLUDE graphics/sprite.i
- INCLUDE graphics/view.i
- INCLUDE intuition/intuition.i
- INCLUDE intuition/preferences.i
- INCLUDE utility/utility.i
- INCLUDE libraries/lowlevel.i
- INCLUDE libraries/nonvolatile.i
- INCLUDE lvo/cia_lib.i
- INCLUDE lvo/dos_lib.i
- INCLUDE lvo/exec_lib.i
- INCLUDE lvo/graphics_lib.i
- INCLUDE lvo/icon_lib.i
- INCLUDE lvo/intuition_lib.i
- INCLUDE lvo/layers_lib.i
- INCLUDE lvo/lowlevel_lib.i
- INCLUDE lvo/utility_lib.i
- INCLUDE lvo/mathffp_lib.i
- INCLUDE lvo/mathtrans_lib.i
- ; INCLUDE lvo/nonvolatile_lib.i
- INCLUDE whdload.i
-
- OPT O+ OG+ ;enable optimizing
- OPT P=68020
-
- ORG $400
- OUTPUT OSEmu.400
- ENDC
-
- USPLENGTH=$2000 ;reserved area for USP, enlarge if necessary
-
- CORRECTDEVICES=1 ;if set 0, module will be assembled with
- ;cut-down devices (no list connection, no
- ;msgport of td.dev, no library-like device-
- ;structure)
-
- ;;BIG_OSEMU = 1 ;if set, OSEmu will be bigger, but richer
-
- ; macros copied from system includes, but improved for local labels support
-
- DISABLE:MACRO
- MOVE.W #INTF_INTEN,_custom+intena ;(NOT IF_SETCLR)+IF_INTEN
- ADDQ.B #1,IDNestCnt(A6)
- ENDM
-
- ENABLE:MACRO
- SUBQ.B #1,IDNestCnt(A6)
- BGE.S .ENABLE\@
- MOVE.W #INTF_SETCLR!INTF_INTEN,_custom+intena ;IF_SETCLR+IF_INTEN
- .ENABLE\@:
- ENDM
-
- ; cleaner way to fix illegal memory constants
-
- VAL_DDDDDDDD = $DDDDDDDD
- VAL_EEEEEEEE = $EEEEEEEE
-
- ;---------------------------------------------------------------------------*
- **************************************************************************
- * INITIALIZATION CALL *
- **************************************************************************
-
- bra.w _Init
- CNOP 0,4 ;essential for correct OSEmu-Structure !
-
- **************************************************************************
- * GLOBAL VARIABLES *
- **************************************************************************
-
- ;-------------------------------------------------------------------------
- ; the following data are part of the OSEmu structure, the offsets of these
- ; data are guaranteed to remain unchanged for all future versions
-
- VERSION = 1
- RELEASE = 45 ; to increase each time the binary is delivered
-
- OSM_SLVTRAINER DC.L 0 ;OSEmu-Offset = 4
- OSM_LASTLOADSEG dc.l 0 ;OSEmu-Offset = 8
- OSM_ID dc.b "OSEM" ;OSEmu-Offset = 12 : added by JOTD
- OSM_VER dc.w VERSION ;OSEmu-Offset = 16 : ""
- dc.w RELEASE ;OSEmu-Offset = 18 : ""
- dc.l 0 ;OSEmu-Offset = 20 : vacant
- OSM_ICONIFYCODE dc.l 0 ;OSEmu-Offset = 24 : ""
- OSM_ICONIFYKEY dc.l 0 ;OSEmu-Offset = 28 : ""
- OSM_UNUSED dc.l 0 ;OSEmu-Offset = 32 : ""
- OSM_EXPMEM dc.l 0 ;OSEmu-Offset = 36 : ""
- OSM_EXPSIZE dc.l 0 ;OSEmu-Offset = 40 : ""
- OSM_DEBUGENTRY dc.l 0 ;OSEmu-Offset = 44 : ""
- OSM_JOYPAD1KEYS dc.w $5455,$5657,$5859 ;keys F5-F10 for pad1, offs.48
- OSM_JOYPAD0KEYS dc.w $0506,$0708,$090a ;keys 5-0 for pad0, offset 54
- OSM_COPLIST1 dc.l 0 ; offset 58 system copper list 1 value
- OSM_COPLIST2 dc.l 0 ; offset 62 system copper list 2 value
- OSM_WRITE_BUFSIZE dc.l DEFAULT_WRITE_BUFSIZE ; offset 66 default dos.Write buffer
- OSM_PORTS_CONFIG
- dc.b JP_TYPE_GAMECTLR,JP_TYPE_GAMECTLR ; 2 joypads connected
- dc.l 0,0,0,0,0,0,0 ; future use
-
-
- **************************************************************************
- * VERSION *
- **************************************************************************
-
- IFND BARFLY
- DC.B 0,"$VER: OS_EMUMODULE ",VERSION+'0',".",RELEASE/10+'0',(RELEASE-(RELEASE/10)*10)+'0'," (20/11/00)",0
- ELSE
- dc.b "$VER: OSEmu ",VERSION+'0',".",RELEASE/10+'0',(RELEASE-(RELEASE/10)*10)+'0'," "
- DOSCMD "WDate >T:date"
- INCBIN "T:date"
- dc.b " by Harry/MrLarmer/WEPL/JOTD",10,0
- dc.b "$Id: osemu.asm 1.1 2000/20/05 04:10:48 jotd Exp jotd $"
- ENDC
- EVEN
-
- ;-------------------------------------------------------------------------
-
- ALLOCMTABSIZE DC.L 0 ; chip memory
- ALLOCFASTMTABSIZE DC.L 0 ; fast memory
- _Slave dc.l 0
- _RESLOAD dc.l 0
- _dosbase dc.l 0
- _gfxbase dc.l 0
- _intbase dc.l 0
- _ilibbase dc.l 0
- _laybase dc.l 0
- _mffpbase dc.l 0
- _mtrbase dc.l 0 ; added by JOTD
- _lowlbase dc.l 0 ; added by JOTD
- _utilbase dc.l 0 ; added by JOTD
- _keymbase dc.l 0 ; added by JOTD
- _loclbase dc.l 0 ; added by JOTD
- _dskfbase dc.l 0 ; added by JOTD
- _franbase dc.l 0 ; added by JOTD
- _nonvbase dc.l 0 ; added by JOTD
- _diskbase dc.l 0 ; added by JOTD
- _miscbase dc.l 0 ; added by JOTD
- _ciaabase dc.l 0
- _ciabbase dc.l 0
- _inputhandler dc.l 0 ;input.device handler (interrupt server structure)
- _inputevent ds.b ie_SIZEOF
- _tags dc.l WHDLTAG_ATTNFLAGS_GET
- dc.w 0
- _attnflags dc.w 0
- dc.l WHDLTAG_ECLOCKFREQ_GET
- _eclockfreq dc.l 0
- dc.l WHDLTAG_MONITOR_GET
- _monitor dc.l 0
- dc.l WHDLTAG_CHIPREVBITS_GET
- _chiprev dc.l 0
- dc.l WHDLTAG_Private3
- _p3 dc.l 0
- dc.l 0
-
- _libtable dc.l _dosname,DOSINIT
- dc.l _gfxname,GFXINIT
- dc.l _intname,INTUIINIT
- dc.l _execname,EXEC2INIT
- dc.l _ilibname,ILIBINIT
- dc.l _layname,LAYERSINIT
- dc.l _lowlname,LOWLINIT
- dc.l _franname,FRANINIT
- dc.l _nonvname,NONVINIT
- dc.l _egsname,EGSINIT
-
- IFD BIG_OSEMU
- dc.l _mtrname,MATHTRANSINIT
- ENDC
- dc.l _mffpname,MATHFFPINIT
- dc.l _utilname,UTILINIT
- dc.l _keymname,KEYMINIT
- dc.l _loclname,LOCLINIT
- dc.l _dskfname,DSKFINIT
-
- dc.l 0
- _restable dc.l _ciaaname,CIAAINIT
- dc.l _ciabname,CIABINIT
- dc.l _diskname,DISKINIT
- dc.l _miscname,MISCINIT
- dc.l 0
-
- _devtable
- _tddevtable DC.L _tdname,0
- _inpdevtable DC.L _inpname,0
- _auddevtable DC.L _audname,0
- _cddevtable DC.L _cdname,0
- _cdtvdevtable DC.L _cdtvname,0
- _kbdevtable DC.L _kbdevname,0
- _condevtable DC.L _condevname,0
- _timerdevtable DC.L _timerdevname,0
- DC.L 0
-
- ; added by JOTD
- sec_timer:
- dc.l $295A6D00 ; in year 2000, sometime
- microsec_timer:
- dc.l 0
- microsec_timer_vbl:
- dc.l 0
- microsec_vbl_interval:
- dc.l 0
- potinp_value:
- dc.w $FFFF
-
- _last_joy0dat dc.w 0
- cnop 0,4
-
- _sprites dc.l -1,-1,-1,-1,-1,-1,-1,-1
-
- even
- KBDQUALIFIER DC.B 0
- DC.B 0
-
- _last_lmb dc.b 0
- _last_rmb dc.b 0
-
- _mffpname dc.b 'mathffp.library',0
- _layname dc.b 'layers.library',0
- _ilibname dc.b 'icon.library',0
- _execname dc.b "exec.library",0
- _dosname dc.b "dos.library",0
- _gfxname dc.b "graphics.library",0
- _intname dc.b "intuition.library",0
- _lowlname dc.b "lowlevel.library",0 ; added by JOTD
- _utilname dc.b "utility.library",0 ; added by JOTD
- _dskfname dc.b "diskfont.library",0 ; added by JOTD
- _keymname dc.b "keymap.library",0 ; added by JOTD
- _loclname dc.b "locale.library",0 ; added by JOTD
- _franname dc.b "freeanim.library",0 ; added by JOTD
- _nonvname dc.b "nonvolatile.library",0 ; added by JOTD
- _mtrname dc.b "mathtrans.library",0 ; added by JOTD
- _egsname dc.b 'egs.library',0
- _ciaaname dc.b "ciaa.resource",0
- _ciabname dc.b "ciab.resource",0
- _diskname dc.b "disk.resource",0
- _miscname dc.b "misc.resource",0
- EVEN
- _tdname dc.b 'trackdisk.device',0
- EVEN
- _inpname dc.b 'input.device',0
- EVEN
- _audname dc.b 'audio.device',0
- EVEN
- _cdname dc.b 'cd.device',0
- EVEN
- _cdtvname dc.b 'cdtv.device',0
- EVEN
- _kbdevname dc.b 'keyboard.device',0
- EVEN
- _condevname dc.b 'console.device',0
- EVEN
- _timerdevname dc.b 'timer.device',0
-
- CNOP 0,4
-
- ;task gets a process structure
-
- _EXECLIBTASK DC.L 0
- DC.L 0
- DC.B NT_PROCESS
- DC.B 0
- DC.L _execname
- DC.B 0
- DC.B TS_RUN
- DC.B 0
- DC.B 0
- DC.L 0 ;TC_SIGALLOC
- DC.L 0
- DC.L 0
- DC.L 0
- DC.W 0
- DC.W 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0 ; tc_UserData
-
- DC.L 0
- DC.L 0
- DC.L 0
- DC.B 0
- DC.B 0
-
- DC.L 0
-
- ; end of task, start of process fields
-
- _EXECLIBMSGPORT DC.L 0
- DC.L 0
- DC.B NT_MSGPORT
- DC.B 0
- DC.L 0
-
- DC.B PA_SIGNAL
- DC.B 0 ;BIT 0 AS SIGNALBIT
- DC.L _EXECLIBTASK
-
- DC.L 0 ;NO MESSAGES YET
- DC.L 0
- DC.L 0
- DC.B NT_MESSAGE
- DC.B 0
-
-
- DC.W 0
-
- _bcplcorrect3
- DC.L _EXECSEGLIST
- DC.L USPLENGTH-$20 ;StackSize
- DC.L $EEEEEEEC ;INVALID GLOBVEC
- DC.L 1 ;task number=1
- DC.L 0
- DC.L 0
-
- DC.L 0 ;CurrentDir
- DC.L 0 ; Current Input Stream
- DC.L OUTPUT_HANDLER_MAGIC ; Current Output Stream (JOTD)
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- _bcplcorrect1 DC.L _CLI ;pointer on CLI structure
- DC.L VAL_EEEEEEEE
- DC.L 0
- DC.L -1
- ;disabled, only for Kick 2.x and higher
- ; DC.L VAL_EEEEEEEE ;homedir
- ; DC.L 0 ;flags
- ; DC.L 0 ;exitcode
- ; DC.L VAL_EEEEEEEE ;exitdata
- _EXECLIBPROCESS_SIZEOF
-
- IFNE _EXECLIBMSGPORT-_EXECLIBTASK-$5C
- FAIL
- ENDC
-
- IFNE _EXECLIBPROCESS_SIZEOF-_EXECLIBTASK-$BC
- FAIL
- ENDC
-
- _DOSLIST
- dc.l 0
- dc.l DLT_VOLUME
- dc.l _EXECLIBMSGPORT
- dc.l $EEEEEEE3
- dc.l $EEEEEEE0
- dc.l $EEEEEEE1
- dc.l $EEEEEEE2
- dc.l $EEEEEEE3
- dc.l $EEEEEEE0
- dc.l $EEEEEEE1
- dc.l $EEEEEEE2
- dc.l $EEEEEEE3
- dc.l $EEEEEEE0
- dc.l $EEEEEEE1
- dc.l $EEEEEEE2
- dc.l $EEEEEEE3
-
- CNOP 0,4 ; must be longword aligned, because pointed by a BCPL pointer
-
- _EXECSEGLIST:
- dc.l $EEEEEEE0
- dc.l $EEEEEEE1
- dc.l $EEEEEEE2 ; 3 above are ROM segments, in the real life
- LastSegList2:
- dc.l $EEEEEEE3 ; our seglist
-
- CNOP 0,4 ; must be longword aligned, because pointed by a BCPL pointer
-
- _CLI DC.L 0
- DC.L $EEEEE1E/4 ; /4 because if accessed it's in BCPL
- DC.L $EEEEEE2
- DC.L 0 ; returncode
- _bcplcorrect2 DC.L _BCPL_CommandName
- DC.L 20
- DC.L $EEEEEE3
- DC.L $EEEEEE4
- DC.L $EEEEEE5
- DC.L $EEEEEE6
- DC.L 0
- DC.L 0
- DC.L $EEEEEE7
- DC.L (USPLENGTH-$20)/4 ; default stack (in longwords)
- DC.L $EEEEEE8
- LastSegList:
- DC.L $EEEEEE9
-
- CNOP 0,4 ; BCPL pointer
- _BCPL_CommandName
- blk.b $40,0 ; was 8,'df0:anim',0, but needed to be changed by LoadSeg()
-
- EVEN
-
- _EXECMINSIZE
-
- DS.B 822 ;-_LVOExecReserved08
-
- INITLIST:MACRO
- move.l A1,LH_TAILPRED(A1) ; tailpred = head (empty list)
- addq.l #4,A1
- clr.l (A1) ; tail = NULL
- move.l A1,-(A1) ; head points on tail
- ENDM
-
- INTSTRUCT:MACRO
- dc.l VAL_DDDDDDDD
- dc.l VAL_DDDDDDDD
- dc.l VAL_DDDDDDDD
- ENDM
- SOFTINT:MACRO
- dc.l 0,0,0,0
- ENDM
-
- _EXECLIBBASE
- DC.L _LIBLIST+4
- DC.L _LIBLIST
- DC.B NT_LIBRARY
- DC.B 0
- DC.L _execname
- ;end of node structure
- DC.B 4
- DC.B $EE
- DC.W -_LVOCopyMemQuick
- DC.W $24C
- DC.W $28 ;version of exec.lib=KS3.1
- DC.W $0A ;subversion
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W 0
- ;end of library structure
- DC.W $44 ;version: KS3.1
- DC.W $EEEE ;checksum
- DC.L VAL_EEEEEEEE ;ChkBase
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L 0
- DC.L VAL_EEEEEEEE
- DC.L 0
- DC.W $EEEE ;ChkSum
-
- ; interrupt structures
-
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
- INTSTRUCT
-
- DC.L _EXECLIBTASK ; ThisTask offset
- DC.L VAL_EEEEEEEE ; IdleCount
- DC.L VAL_EEEEEEEE ; DispCount
- DC.W $EEEE ; Quantum
- DC.W $DDDD ; Elapsed
- DC.W $EEEE ; SysFlags
- DC.B -1 ; IdNestCnt
- DC.B -1 ; TdNestCnt
- DC.W 0 ; AttnFlags
- DC.W 0 ; AttnResched
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE ;DUMMY, NORMALLY ALLOCATED SIGNALS
- DC.W $EEEE
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
-
- IFNE CORRECTDEVICES
- _DEVLISTC DC.L _DEVLISTC+4
- DC.L 0
- DC.L _DEVLISTC
- DC.B NT_DEVICE
- DC.B 0
- ELSE
- DC.L VAL_EEEEEEEE ;DEVICELIST
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
- ENDC
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
-
- _LIBLIST DC.L _EXECLIBBASE
- DC.L 0
- DC.L _EXECLIBBASE
- DC.B NT_LIBRARY
- DC.B 0
-
- ; lists, empty at start
-
- _PORTSLIST DC.L _PORTSLIST+4 ; added by JOTD
- DC.L 0
- DC.L _PORTSLIST
- DC.B NT_MSGPORT
- DC.B 0
-
- _TASKREADYLIST DC.L _TASKREADYLIST+4
- DC.L 0
- DC.L _TASKREADYLIST
- DC.B NT_TASK
- DC.B 0
-
- _TASKWAITLIST DC.L _TASKWAITLIST+4 ; added by JOTD
- DC.L 0
- DC.L _TASKWAITLIST
- DC.B NT_TASK
- DC.B 0
-
- _SOFTINT0
- SOFTINT
- SOFTINT
- SOFTINT
- SOFTINT
- SOFTINT
-
- ; last alert
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
-
- DC.B $EE ;VBLANK FREQU
- DC.B $EE ;POWER SUPPLY FREQU
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
-
- DC.L VAL_EEEEEEEE
- DC.L VAL_EEEEEEEE
- DC.W $EEEE
-
- DS.B 12
- DS.B 20
- DS.B $2C
- _EMAXSIZE
-
- IFNE _EMAXSIZE-_EXECLIBBASE-$278
- FAIL
- ENDC
-
-
- IFNE CORRECTDEVICES
- _TDDMSGPORT
- DC.L 0
- DC.L 0
- DC.B NT_MSGPORT
- DC.B 0
- DC.L _tdname
-
- dc.b 0
- dc.b 0
- DC.L _EXECLIBTASK
-
- DC.L 0
- DC.L 0
- DC.L 0
- DC.B NT_MESSAGE
- DC.B 0
-
- DC.L 1 ;DUE LORDS OF WAR -UNDOCUMENTED-
-
- ENDC
-
- cnop 0,4
- _DummyCList: ; added by JOTD
- dc.l $FFFFFFFE
-
- _Multitasks:
- dc.w 0
-
- **************************************************************************
- * GLOBAL INITIALIZATION *
- **************************************************************************
- ;REQUIRES NOW AT LEAST WHDLOAD 7.0
- ;ALTHOUGH THERE IS NO MULTITASKING IMPLEMENTED AT THE MOMENT,
- ;ALL FUNCTIONS MUST BE IMPLEMENTED REENTRANTLY
- ;
- ; IN: A0 = resload base
- ; A1 = pointer to slave structure
- ; OUT: A1 = ioreq of trackdisk.device
- ; A6 = execbase
-
- _Init movem.l d0-a0/a2-a5,-(a7)
-
- move.l $4.W,a6
-
- cmp.w #7,(ws_Version,a1) ;minimum version
- blo _ill
-
- move.l a0,_RESLOAD
- move.l a1,(_Slave)
-
- ;install a default copperlist
-
- move.l #_DummyCList,(_custom+cop1lc)
-
- ;correct structures
- BCPLCORRECT MACRO
- move.l \1,d0
- lsr.l #2,d0
- move.l d0,\1
- ENDM
- BCPLCORRECT _bcplcorrect1
- BCPLCORRECT _bcplcorrect2
- BCPLCORRECT _bcplcorrect3
- BCPLCORRECT _bcplcorrect6
- BCPLCORRECT _bcplcorrect7
- BCPLCORRECT _bcplcorrect8
-
- ;init memory managment
-
- ; chip memory
-
- lea _osemu_end,a0 ;FIRST CLEAR WHOLE TABLE (MARK MEM AS USED)
- move.l (ws_BaseMemSize,a1),d0
- SUBQ.L #8,D0
- LSR.L #3,D0 ;OK, AMOUNT OF BITS TO CLEAR IS IN D0
- LSR.L #3,D0 ;AMOUNT OF BYTES TO CLEAR IN D0
- .1 CLR.B (A0)+
- SUBQ.L #1,D0
- BPL.S .1
- MOVE.L A0,ALLOCMTABSIZE
- move.l (ws_BaseMemSize,a1),d0
- SUB.L A0,D0
- SUB.L #$1000,D0 ;$1000 SYSTEM STACK ON TOP
- MOVE.L A0,A1 ;FREE APPROPRIATE SIZE
- BSR _FreeMem
-
- ; fast memory if available
-
- move.l OSM_EXPMEM,a0 ;FIRST CLEAR WHOLE TABLE (MARK MEM AS USED)
- cmp.l #0,A0
- beq.b .nofast
-
- move.l OSM_EXPSIZE,d0
- SUBQ.L #8,D0
- LSR.L #3,D0 ;OK, AMOUNT OF BITS TO CLEAR IS IN D0
- LSR.L #3,D0 ;AMOUNT OF BYTES TO CLEAR IN D0
- .2 CLR.B (A0)+
- SUBQ.L #1,D0
- BPL.S .2
- MOVE.L A0,ALLOCFASTMTABSIZE ; not real size!
-
- move.l OSM_EXPSIZE,d0
- add.l OSM_EXPMEM,D0 ; adds expbase
- SUB.L A0,D0 ; substracts expbase+tabsize
- SUB.L #$100,D0 ;$100 safety
-
- MOVE.L A0,A1 ;FREE APPROPRIATE SIZE
- BSR _FreeMem
-
- .nofast:
- ;allocate stack
- move.l #USPLENGTH,d0
- moveq #MEMF_PUBLIC,d1 ; MEMF_CHIP removed
- bsr _AllocMem
- move.l d0,a0
- MOVE.L A0,_EXECLIBTASK+TC_SPLOWER
- add.l #USPLENGTH-4,a0
- move.l a0,usp
- MOVE.L A0,_EXECLIBTASK+pr_StackBase
- MOVE.L #USPLENGTH-$20,(A0)+
- MOVE.L A0,_EXECLIBTASK+TC_SPUPPER
-
- ;get whdload vars
- lea _tags,a0
- move.l _RESLOAD,a1
- jsr (resload_Control,a1)
-
- ;init libraries
- bsr CIAAINIT ;required because int handling
- bsr CIABINIT ;required because int handling
- bsr EXECINIT
- bsr GFXINIT ;required for display init (copper)
- IFNE CORRECTDEVICES
- BSR.W MAKEDEVICELIST
- ENDC
-
- ; acknowledge keyboard
-
- bsr AckKeyboard
-
- ; enables interrupts (first clear all requests)
- move.w #$7FFF,(_custom+intreq)
- move.w #INTF_SETCLR!INTF_INTEN!INTF_EXTER!INTF_VERTB!INTF_PORTS,(_custom+intena)
-
-
- ;flush caches
- move.l (_RESLOAD),a0
- jsr (resload_FlushCache,a0)
-
- ;prepare return values
- ; > A1: diskio of trackdisk.device, filled with READ command
- ; > A6: execbase
-
- move.l $4.W,a6
- move.l #$400+IOTD_SIZE,d0
- moveq #0,d1
- bsr _AllocMem
- move.l d0,a2
- lea (_tdname),a0
- moveq #0,d0
- move.l a2,a1
- moveq #0,d1
- JSRLIB OpenDevice
- move.l a2,a1
- lea (IOTD_SIZE,a2),a0
- move.l a0,(IO_DATA,a1)
- move.l #$400,(IO_LENGTH,a1)
- clr.l (IO_OFFSET,a1)
- move.w #CMD_READ,(IO_COMMAND,a1)
-
- movem.l (a7)+,d0-a0/a2-a5
-
- ; ready for multitasking
-
- move.w #1,_Multitasks
-
- rts
-
- ; Added by JOTD: enter debugger (useful for debugging with JST)
-
- EnterDebugger:
- tst.l OSM_DEBUGENTRY
- beq.b .exit
- pea .exit(pc)
- move.l OSM_DEBUGENTRY,-(A7)
- rts
- .exit
- rts
-
- **************************************************************************
- * MISC FUNCTIONS *
- **************************************************************************
- ;-----------------------------------------------
- ; IN: D0 = ULONG size of jmp table
- ; D1 = ULONG size of variable area
- ; A0 = CPTR subsystem name
- ; OUT: D0 = APTR librarybase
-
- _InitStruct movem.l d0-d1/a0,-(a7)
- add.l d1,d0
- move.l #MEMF_CLEAR,d1 ;changed by JOTD
- bsr _AllocMem
- move.l d0,a0 ;jmp table start
- move.l d0,a1
- add.l (a7),a1 ;jmp table end
-
- lea _LVOFail,a2
- .1 move.w #$4EB9,(A0)+
- move.l a2,(a0)+
- cmp.l a0,a1
- bhi .1
- move.l (8,a7),-4(a0) ;name of library
- move.l a0,(A7) ;library base
- move.l a0,a1 ;variables start
- add.l (4,a7),a1 ;variables end
- .2 move.w #$eeee,(a0)+
- cmp.l a0,a1
- bhi .2
- MOVEM.L (A7)+,D0/D1/A0
- rts
-
- _InitLibrary BSR.S _InitStruct
- MOVE.L D0,A1
- MOVE.B #NT_LIBRARY,LN_TYPE(A1)
- SF LN_PRI(A1)
- move.l A0,LN_NAME(A1) ;name of library
- LEA.L _LIBLIST(PC),A0
- BSR.W _ADDTAIL
- rts
-
- IFNE CORRECTDEVICES
- _InitDevice BSR.S _InitStruct
- MOVE.L D0,A1
- MOVE.B #NT_LIBRARY,LN_TYPE(A1)
- SF LN_PRI(A1)
- move.l A0,LN_NAME(A1) ;name of library
- LEA.L _DEVLISTC(PC),A0
- BSR.W _ADDTAIL
- rts
- ENDC
-
- _LVOFail exg.l d0,a6
- sub.l d0,(a7) ;LVO
- exg.l d0,a6
- subq.l #6,(a7)
- move.l (-4,a6),-(a7) ;name of library
- _emufail pea TDREASON_OSEMUFAIL
- move.l _RESLOAD(pc),-(a7)
- addq.l #resload_Abort,(a7)
- _rts rts
-
- EMUFAIL MACRO
- pea \1
- pea \2
- bra _emufail
- ENDM
- EXECFAIL MACRO
- EMUFAIL \1,_execname
- ENDM
- GFXFAIL MACRO
- EMUFAIL \1,_gfxname
- ENDM
-
- ;-----------------------------------------------
- ; IN: A0 = CPTR string 1
- ; A0 = CPTR string 2
- ; OUT: D0 = LONG 0 if strings are equal
-
- _strcmp movem.l a0-a1,-(a7)
- .1 cmpm.b (a0)+,(a1)+
- bne .not
- tst.b (-1,a0)
- bne.b .1
- moveq.l #0,d0 ; bugfix: move.w #0,d0 was there!
- movem.l (a7)+,a0-a1
- rts
-
- .not moveq.l #-1,d0
- movem.l (a7)+,a0-a1
- rts
-
- ;-----------------------------------------------
- ; wait for vertical blank
-
- _waitvb
- .1 btst #0,(_custom+vposr+1)
- beq .1
- .2 btst #0,(_custom+vposr+1)
- bne .2
- rts
-
- _ill illegal
-
- **************************************************************************
- * EXEC LIBRARY *
- **************************************************************************
-
- EXEC2INIT
- move.l A6,D0 ; NightShift tries to open exec.library!
- rts
-
- **************************************************************************
- * INITIALIZATION *
- **************************************************************************
-
- EXECINIT
- ; move.l 4,d0
- ; btst #0,d0
- ; bne .init
- ; rts
-
- .init lea _EXECMINSIZE(PC),A0
- LEA.L _EXECLIBBASE(PC),A1
- lea _LVOFail,a2
- .1 move.w #$4EB9,(A0)+
- move.l a2,(a0)+
- cmp.l a0,a1
- bhi .1
- move.l #_execname,-4(a0) ;name of library
- MOVE.L a1,a0
- move.l a0,$4.W
-
- patch _LVORawDoFmt(A0),RAWDOFMT
- patch _LVOOldOpenLibrary(a0),OPENLIB
- patch _LVOOpenLibrary(a0),OPENLIB
- patch _LVOCloseLibrary(A0),MYRTS
- patch _LVODebug(A0),_Debug
-
- patch _LVOAllocMem(a0),_AllocMem
- patch _LVOFreeMem(a0),_FreeMem
- patch _LVOAllocVec(a0),_AllocVec
- patch _LVOFreeVec(a0),_FreeVec
- patch _LVOAvailMem(a0),_AvailMem
- patch _LVOTypeOfMem(a0),TYPEOFMEM
- patch _LVOAllocAbs(a0),_AllocAbs
- patch _LVOCopyMem(A0),_COPYMEM
- patch _LVOCopyMemQuick(A0),_COPYMEMQUICK
- patch _LVOAllocEntry(a0),ALLOCENTRY
- patch _LVOFreeEntry(a0),FREEENTRY
-
- patch _LVOForbid(a0),_Forbid
- patch _LVOPermit(a0),_Permit
- patch _LVOCause(A0),_Cause
- patch _LVOSetIntVector(A0),_SETINTVECTOR
- patch _LVOAddIntServer(a0),_AddIntServer
- patch _LVORemIntServer(a0),_RemIntServer
- patch -$24(A0),_ExitIntr
- patch _LVOEnqueue(a0),_Enqueue
- patch _LVOOpenResource(a0),OPENRES
- patch _LVOSupervisor(a0),_Supervisor
- patch _LVOSuperState(a0),_SuperState
- patch _LVOUserState(a0),_UserState
- patch _LVOFindTask(a0),_FindTask
- patch _LVORemTask(a0),MYRTS
- patch _LVOSetTaskPri(A0),MYRTZ
-
- patch _LVOAddPort(a0),_AddPort
- patch _LVOOpenDevice(a0),_OpenDevice
- patch _LVODoIO(a0),_DoIO
- patch _LVOWaitIO(A0),_WAITIO ; uncommented by JOTD
- patch _LVOAbortIO(A0),_ABORTIO
- patch _LVOCheckIO(A0),_CHECKIO ; added by JOTD
- patch _LVOSendIO(a0),_SendIO
- patch _LVOCloseDevice(a0),MYRTS
- patch _LVORemPort(a0),_RemPort
-
- patch _LVOAllocSignal(a0),_AllocSignal
- patch _LVOFreeSignal(a0),_FreeSignal
- patch _LVOSetSignal(a0),_SetSignal
- patch _LVODisable(a0),_Disable
- patch _LVOEnable(a0),_Enable
- ;;; patch _LVOWaitPort(A0),_WaitPort ; unplugged ATM
- patch _LVOGetMsg(A0),_GetMsg
- patch _LVOPutMsg(A0),_PutMsg
- patch _LVOReplyMsg(A0),_ReplyMsg
- patch _LVOCreateIORequest(A0),_CreateIORequest
- patch _LVODeleteIORequest(A0),_DeleteIORequest
- patch _LVOCreateMsgPort(A0),_CreateMsgPort
- patch _LVODeleteMsgPort(A0),_DeleteMsgPort
- ;;; patch _LVOAddTask(a0),_AddTask ; added by JOTD, unplugged
-
- patch _LVOInsert(A0),_INSERT
- patch _LVOAddHead(A0),_ADDHEAD
- patch _LVOAddTail(A0),_ADDTAIL
- patch _LVORemove(A0),_REMOVE
- patch _LVORemHead(A0),_REMHEAD
- patch _LVORemTail(A0),_REMTAIL
- patch _LVOFindName(A0),_FINDNAME
- patch _LVOFindPort(A0),_FINDPORT
-
- patch _LVOCacheControl(A0),_CacheControl ; added by JOTD
- patch _LVOCacheClearU(A0),_CacheClearU ; added by JOTD
- patch _LVOSetFunction(A0),_SetFunction ; added by JOTD
- patch _LVOFindResident(A0),_FindResident ; added by JOTD
- patch _LVOStackSwap(a0),STACKSWAP ; added by JOTD (PGAGolf)
- patch _LVOGetCC(a0),_GETCC ; added by JOTD (Lunar-C)
-
- ;;;;; patch _LVOWait(A0),MYRTS ; JOTD, dummy!
-
- move.w (_attnflags),(AttnFlags,a0)
-
- MOVE.L _Slave(PC),A1
- MOVE.L ws_BaseMemSize(A1),A1
- MOVE.L A1,SysStkUpper(A0)
- MOVE.L A1,MaxLocMem(A0)
- LEA.L -$1000(A1),A1
- MOVE.L A1,SysStkLower(A0)
- MOVE.L _monitor(PC),D0
- MOVEQ.L #60,D1
- AND.L #$FFFF1000,D0
- CMP.L #$21000,D0
- BNE.S .nopal
- moveq.l #50,D1
- .nopal
- move.b d1,VBlankFrequency(A0)
-
- ; JOTD, for timer.device
-
- move.l #1000000,D0
- divu D1,D0 ; number of microsecs between VBL interrupt
- move.w D0,microsec_vbl_interval+2
-
- ;clear int table
- lea (IntVects,a0),a1
- moveq #16*IV_SIZE/4-1,d0
- .c1 MOVE.L #VAL_DDDDDDDD,(a1)+
- dbf d0,.c1
-
- ;init int table
- LEA.L (IVPORTS,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_CIAA,(IV_NODE,a1)
-
- LEA.L (IVCOPER,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- CLR.L (IV_NODE,a1)
-
- LEA.L (IVVERTB,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- CLR.L (IV_NODE,a1)
-
- LEA.L (IVEXTER,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_CIAB,(IV_NODE,a1)
-
- LEA.L (IVAUD0,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_AUDIO0,(IV_NODE,a1)
-
- LEA.L (IVAUD1,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_AUDIO1,(IV_NODE,a1)
-
- LEA.L (IVAUD2,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_AUDIO2,(IV_NODE,a1)
-
- LEA.L (IVAUD3,A0),A1
- MOVE.L A1,(IV_DATA,a1)
- MOVE.L #INT_SERVER,(IV_CODE,A1)
- move.l #INTSERVNODE_AUDIO3,(IV_NODE,a1)
-
- ;init hardware ints
- move.l #INT_64,$64.W
- move.l #INT_68,$68.W
- move.l #INT_6c,$6C.W
- MOVE.L #INT_70,$70.W
- move.l #INT_78,$78.W
-
- move.b #$1f,$bfed01
-
- MOVE.B #$80+CIAA_INT_VAL,$BFED01
-
- tst.B $BFED01
- move.b #$1f,$bfdd00
- ; MOVE.B #$87,$BFDD00 ; OS doesn't enable TOD int (Mr.Larmer)
- MOVE.B #$8+CIAB_INT_VAL,$BFDD00
- tst.b $bfdd00
-
- move.w #$7fff,(_custom+intena)
-
- rts
-
- IFNE CORRECTDEVICES
- MAKEDEVICELIST
- MOVE.L 4.W,A0
- move.l #$24,d0
- ; move.l #LIB_SIZE,d1
- move.l #LIB_SIZE+$a,d1
- lea _tdname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_tddevtable+4
- MOVE.L D0,A0
- CLR.L $28(A0) ;DUE LORDS OF WAR
- MOVE.L #_TDDMSGPORT,$24(A0) ;-"-
-
- ; keyboard device
-
- move.l #$24,d0
- ; move.l #LIB_SIZE,d1
- move.l #$14C,d1
- lea _kbdevname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_kbdevtable+4
-
- move.l d0,INTSERVNODE_SP+IS_DATA
-
- move.l d0,a0
- lea $70(a0),a0
- move.l #$14C-$70-1,d0
- .clear
- clr.b (a0)+
- dbf d0,.clear
-
- ; input.device
-
- move.l #$24,d0
- move.l #LIB_SIZE,d1
- lea _inpname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_inpdevtable+4
-
- ; audio.device
-
- move.l #$24,d0
- move.l #LIB_SIZE,d1
- lea _audname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_auddevtable+4
-
- MOVE.L D0,A0
- patch -$1E(A0),_SENDAUDIO
-
- ; cd.device, added by JOTD
-
- move.l #$24,d0
- move.l #LIB_SIZE,d1
- lea _cdname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_cddevtable+4
-
- ; cdtv.device, added by JOTD
-
- move.l #$24,d0
- move.l #LIB_SIZE,d1
- lea _cdtvname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_cdtvdevtable+4
-
- ; dummy console.device
-
- move.l #$24,d0
- move.l #LIB_SIZE,d1
- lea _condevname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_condevtable+4
-
- move.l D0,A0
- patch -$24(a0),_RawKeyConvert ; needed by Wings. RawKeyConvert, but wrong offset!
-
- ; timer.device
-
- move.l #$24,d0
- ;; move.l #LIB_SIZE,d1
- move.l #$C4,d1 ; Jeff, to store ciaa.resource pointer
- lea _timerdevname(PC),a0
- bsr _InitDevice
- MOVE.L d0,_timerdevtable+4
-
- MOVE.L D0,A0
- patch _LVOReadEClock(A0),_READECLOCK ; ROM 3.1 at $FC10F8
-
- ; stores execbase
-
- move.l $4.W,$24(A0)
-
- ; opens ciaa.resource
-
- bsr .openciaa
-
- ; enable CIA-B timer B: starts running
-
- move.b #%00000001,$bfef01
-
- RTS
-
- ENDC
-
- .openciaa:
- MOVEM.L A0/A1/D1,-(A7)
- LEA _ciaaname,A1
- bsr OPENRES
- MOVEM.L (A7)+,A0/A1/D1
- move.l D0,$C0(A0)
- rts
-
- MYRTZ MOVEQ.L #0,D0
- MYRTS RTS
-
- **************************************************************************
- * MISC EXEC FUCTIONS *
- **************************************************************************
-
- ; < A0: new stack structure
- ; (ripped from OS3.1 ROM)
-
- STACKSWAP:
- MOVE.L $0114(A6),A1
-
- DISABLE
-
- MOVE.L $003E(A1),D0
- MOVE.L $0004(A0),$003E(A1)
- MOVE.L D0,$0004(A0)
- MOVE.L $003A(A1),D0
- MOVE.L (A0),$003A(A1)
- MOVE.L D0,(A0)
- MOVE.L $0008(A0),$0036(A1)
- MOVE.L (A0),A1
- MOVE.L #$BAD1BAD3,(A1) ; illegal value
- MOVE.L $0008(A0),A1
- MOVE.L (A7)+,D0
- MOVE.L A7,$0008(A0)
- MOVE.L D0,-(A1)
- MOVE.L A1,A7
-
- ENABLE
- RTS
-
-
- _CacheControl:
- _CacheClearU:
- movem.l A0,-(A7)
- move.l (_RESLOAD),a0
- jsr (resload_FlushCache,a0)
- movem.l (A7)+,A0
- rts
-
- _FindResident:
- moveq.l #0,D0
- rts
-
- _SetFunction ; added by JOTD (Banshee)
- movem.l D1,-(A7)
- move.l 2(A1,A0.W),D1
- move.l D0,2(A1,A0.W) ; changed
- move.l D1,D0 ; old function
- movem.l (A7)+,D1
- rts
-
- _Supervisor move.l $bc,.s1
- move.l #.c1,$bc.w
- trap #15
- rts
- .c1 move.l .s1,$bc.w
- jmp (a5)
- .s1 dc.l 0
-
- _SuperState MOVE.L A5,A0
- LEA .ac,A5
- JMP _LVOSupervisor(A6)
- .ac MOVE.L A0,A5
- MOVEQ #$00,D0
- BSET #$05,(A7)
- BNE.S .ca
- MOVE.W (A7)+,SR
- MOVE.L A7,D0
- MOVE.L USP,A7
- BTST #$00,$0129(A6)
- BEQ.S .c6
- ADDQ.L #$2,D0
- .c6 ADDQ.L #$4,D0
- RTS
- .ca RTE
-
- _UserState MOVE.L (A7)+,A0
- MOVE.L A7,USP
- MOVE.L D0,A7
- ANDI.W #$dfff,SR
- JMP (A0)
-
- _CreateIORequest
- movem.l D2/D3,-(SP)
- move.l D0,D2
- move.l A0,D3
- beq.s .error
- move.l #$10001,D1
- jsr _LVOAllocMem(A6)
- movea.l D0,A0
- tst.l D0
- beq.s .error
- move.b #NT_REPLYMSG,LN_TYPE(A0)
- move.l D3,MN_REPLYPORT(A0)
- move.w D2,MN_LENGTH(A0)
- .error
- move.l A0,D0
- movem.l (SP)+,D2/D3
- rts
-
- _DeleteIORequest
- move.l A0,D0
- beq.s .abort
- moveq #-1,D0
- move.l D0,LN_SUCC(A0)
- move.l D0,IO_DEVICE(A0)
- moveq #0,D0
- move.w MN_LENGTH(A0),D0
- movea.l A0,A1
- jsr _LVOFreeMem(A6)
- .abort
- rts
-
- _CreateMsgPort
- moveq #MP_SIZE,D0 ;$22,D0
- move.l #$10001,D1
- jsr _LVOAllocMem(A6)
- move.l D0,-(SP)
- beq.s .error
- moveq #-1,D0
- jsr _LVOAllocSignal(A6)
- movea.l (SP),A0
- move.b #NT_MSGPORT,LN_TYPE(A0)
- move.b #PA_SIGNAL,MP_FLAGS(A0)
- move.b D0,MP_SIGBIT(A0)
- bmi.s .abort
- move.l ThisTask(A6),MP_SIGTASK(A0)
- lea MP_MSGLIST(A0),A1
- INITLIST A1
- .error
- move.l (SP)+,D0
- rts
-
- .abort
- moveq #MP_SIZE,D0
- movea.l A0,A1
- jsr _LVOFreeMem(A6)
- clr.l (SP)
- bra.s .error
-
- _DeleteMsgPort
- move.l A0,-(SP)
- beq.s .abort
- moveq #0,D0
- move.b MP_SIGBIT(A0),D0
- jsr _LVOFreeSignal(A6)
- movea.l (SP),A1
- moveq #-1,D0
- move.l D0,MP_MSGLIST(A1)
- move.l D0,LN_SUCC(A1)
- moveq #MP_SIZE,D0
- jsr _LVOFreeMem(A6)
- .abort
- addq.l #4,SP
- rts
-
-
- **************************************************************************
- * Task related functions *
- **************************************************************************
-
- _AllocSignal
- movea.l ThisTask(A6),A1
- move.l TC_SIGALLOC(A1),D1
- cmp.b #-1,D0
- beq.s .search
- bset D0,D1
- beq.s .free
- bra.s .err
-
- .search
- moveq.l #$20-1,D0
- .search2
- bset D0,D1
- beq.s .free
- dbra D0,.search2
- .err
- moveq.l #-1,D0
- rts
-
- .free
- move.l D1,TC_SIGALLOC(A1)
- moveq #-1,D1
- bclr D0,D1
- and.l D1,TC_SIGRECVD(A1)
- and.l D1,TC_SIGEXCEPT(A1)
- and.l D1,TC_SIGWAIT(A1)
- rts
-
- _FreeSignal
- cmp.b #$FF,D0
- beq.s .skip ; Mr Larmer: no more error
- movea.l ThisTask(A6),A1
- move.l TC_SIGALLOC(A1),D1
- bclr D0,D1
- move.l D1,TC_SIGALLOC(A1)
- .skip
- rts
-
-
- _SetSignal MOVE.L ThisTask(A6),A0
- MOVE.L TC_SIGRECVD(A0),-(A7)
- AND.L D1,D0
- NOT.L D1
- AND.L TC_SIGRECVD(A0),D1
- OR.L D0,D1
- MOVE.L D1,TC_SIGRECVD(A0)
- MOVE.L (A7)+,d0
- rts
-
- _Disable
- DISABLE ; we use the macro!
- rts
- _Enable
- ENABLE
- rts
-
- _Forbid:
- ADDQ.B #1,TDNestCnt(A6)
- rts
-
- _Permit:
- SUBQ.B #1,TDNestCnt(A6)
- BPL.B .skip
-
- ; checks if interrupts are allowed
-
- tst.b IDNestCnt(A6)
- bpl.b .skip
-
- ; checks if switch flag is pending (and resets it)
-
- bclr #7,AttnResched(A6)
- beq.b .skip
-
- ; must switch
-
- bsr _Switch
- .skip
- rts
-
- ; Switch, private, AROS implementation
-
- _Switch:
- move.l ThisTask(a6),A1
- cmp.b #TS_RUN,(TC_STATE,A1)
- bne.b .fail ; impossible since task would not be there
-
- ; freeze the task state
-
- move.b #TS_READY,(TC_STATE,A1)
-
- ; Use Reschedule() to put the task in the correct list
-
- bsr _Reschedule
-
- ; sets new, active Task in exec structure
-
- bsr _Dispatch
- .skip
- rts
-
- .fail:
- EMUFAIL _LVOSwitch,_execname
-
- ; Dispatch, private, AROS implementation
-
- _Dispatch:
- move.l (ThisTask,A6),A1 ; current, old task
- lea (TaskReady,A6),A0 ; taskready list
- JSRLIB RemHead ; next ready task
- tst.l D0 ; is there any more task
- beq.b .fail ; no more task to dispatch
-
- ; copy the sysbase nest counts in the old, about to be switched
- ; task nest counts
-
- move.b (TDNestCnt,A6),(TC_TDNESTCNT,A1)
- move.b (IDNestCnt,A6),(TC_IDNESTCNT,A1)
-
- move.l D0,A0 ; incoming task
-
- move.b #TS_RUN,(TC_STATE,A0)
-
- ; copy the task's nest counts to exec nest counts
-
- move.b (TC_TDNESTCNT,A0),(TDNestCnt,A6)
- move.b (TC_IDNESTCNT,A0),(IDNestCnt,A6)
-
- ; now this is the current task
-
- move.l A0,(ThisTask,A6)
-
- ; we should perform stack checks and increase some counters, but
- ; we don't care
-
-
- ; ok, now we get task's user SP
-
-
- rts
-
- .fail:
- EMUFAIL _LVODispatch,_execname
-
- ; Reschedule, private
- ; < A1: task
-
- _Reschedule:
- move.l ThisTask(a6),A1
- move.b (TC_STATE,A1),D0
- cmp.b #TS_READY,D0
- bne.b .s1
- ; insert task in task ready list
-
- lea (TaskReady,A6),A0
- JSRLIB Enqueue
- bra.b .exit
- .s1
- cmp.b #TS_WAIT,D0
- bne.b .s2
- ; insert task in task wait list
-
- lea (TaskWait,A6),A0
- JSRLIB Enqueue
- .s2
- .exit
- rts
-
- ; handle task switching during interrupts
- ; trashes D0-D1/A0-A1
-
- HandleTaskSwitching:
- ; unimplemented !!!
- rts
-
- move.l $4.W,A6
-
- ; sets pending switch flag
-
- bset #7,AttnResched(A6)
-
- ; check if Forbid count is >=0
-
- tst.b TDNestCnt(A6)
- bpl.b .noswitch ; nested Forbid(), don't switch
-
- ; interrupted: tries to switch tasks if any pending
-
- lea 4(A7),A0
-
- move.w (60,A0),D0 ; get SR when interrupt occurred
- btst #13,D0 ; was supervisor?
- bne.b .noswitch ; if so, don't switch right now
-
- ; user mode, not forbidden
-
- move.l (62,A0),D0 ; user PC where the interrupt took place
-
- ; swap current task
-
- bclr #7,AttnResched(A6)
-
- .noswitch
- rts
-
- ; AddTask, added by JOTD
- ; with great help of AROS implementation
-
- ; task regsave struct offsets
-
- STRUCTURE TASKSAVE,0
- ULONG TSV_CURRENTPC
- ULONG TSV_ENDPC
- UWORD TSV_SR ; always user SR
- STRUCT TSV_DR,4*8
- STRUCT TSV_AR,4*7
- LABEL TSV_SIZE
-
- ; < A1: task structure
- ; < A2: initial PC
- ; < A3: final PC (finalizer) or 0 if no finalizer
- ; > D0: pointer on task or NULL if failed
-
- ifeq 1
- _AddTask:
- movem.l D2/A4,-(A7)
- move.l A1,A4
-
- bsr EnterDebugger
-
- move.b #NT_TASK,(LN_TYPE,A4)
- tst.l (LN_NAME,A4)
- bne.b .named
- move.l #.defaultname,(LN_NAME,A4) ; provides default name to the task
- .named
- tst.l (TC_SIGALLOC,A4)
- bne.b .sigset
- move.l #$FFFF,(TC_SIGALLOC,A4)
- .sigset
- ; this is moved to ExecBase at task's startup
- move.b #-1,(TC_IDNESTCNT,A4)
- move.b #-1,(TC_TDNESTCNT,A4)
-
- tst.w (TC_SWITCH,A4)
- beq.b .nosw
- or.b #TF_SWITCH,(TC_FLAGS,A4)
- .nosw
- tst.w (TC_LAUNCH,A4)
- beq.b .noln
- or.b #TF_LAUNCH,(TC_FLAGS,A4)
- .noln
- move.l (TC_SPUPPER,A4),D0
- sub.l #TSV_SIZE,D0 ; allocates stack space to save information
- move.l D0,(TC_SPREG,A4) ; SP register initialize (this is not the real
- ; SP register but rather SP-TSV_SIZE)
-
- ; init tc_MemList if zero
-
- tst.l (TC_MEMENTRY,A4)
- bne.b .memlist_set
- lea (TC_MEMENTRY,A4),A1
- INITLIST A1
- .memlist_set
-
- move.l (TC_SPREG,A4),A1
-
- ; fills in some values (start and end of the task)
-
- move.l A2,(TSV_CURRENTPC,A1)
- move.l A3,(TSV_ENDPC,A1)
-
- ; insert the task in exec task list
-
- JSRLIB Disable
-
- move.b #TS_READY,(TC_STATE,A4) ; mark as ready to run
- lea (TaskReady,A6),A0 ; TaskReady list
- move.l A4,A1 ; task node
- JSRLIB Enqueue ; inserts into exec TaskReady list
-
- ; task priorities not supported yet
-
- JSRLIB Enable
-
- movem.l (A7)+,D2/A4
- RTS
-
- .defaultname:
- dc.b "OSEmu task",0
- even
-
- .fail:
- EMUFAIL _LVOAddTask,_execname
- endif
-
- ; FindTask
- ; < A1: must be NULL or else unsupported
- ; > D0: task structure
-
- _FindTask:
- MOVE.L A1,-(A7) ;fails if not own task searched
- TST.L (A7)+
- BNE.S .FAIL
- MOVE.L 4.W,A0
- MOVE.L ThisTask(A0),D0
- RTS
-
- .FAIL
- pea _LVOFindTask
- pea _execname
- bra _emufail
-
- **************************************************************************
- * MEMORYFUNCTIONS *
- **************************************************************************
-
- ; AllocEntry(): Added by JOTD by request of Bored Seal
- ; Tested on DragonNinja
-
- ; < A0: memList
- ; > D0: allocated memList
-
- ALLOCENTRY:
- movem.l D1-A6,-(A7)
- move.l A0,A5
- moveq.l #0,D0
- move.w LN_SIZE(A5),D0
- lsl.l #3,D0
- add.l #$10,D0
- move.l D0,D5 ; size
- move.l #MEMF_PUBLIC,D1
- jsr (_LVOAllocMem,a6)
- move.l D0,D6
- beq.b .fail
-
- ; allocated OK
-
- move.l D6,A4
-
- moveq.l #0,D0
- move.l A5,A0
- move.l A4,A1
- move.l D5,D0
- jsr (_LVOCopyMem,a6)
-
- moveq.l #0,D2
- move.w LN_SIZE(A4),D2 ; # of items
-
- add.l #LN_SIZE+2,A4
- .loop
- move.l (A4)+,D1 ; flags
- move.l (A4)+,D0 ; size
- jsr (_LVOAllocMem,a6)
- beq.b .fail ; alloc problem
- move.l D0,-8(A4) ; store memblock start in flags (union)
- subq.l #1,D2
- bne.b .loop
-
- move.l D6,D0 ; new memlist
- .exit
- movem.l (A7)+,D1-A6
- rts
-
- .fail:
- moveq.l #0,D0
- bset #31,D0
- bra.b .exit
-
- ; FreeEntry(): still untested but should work
- ; JOTD: it does NOT
-
- FREEENTRY:
-
- movem.l D1-A6,-(A7)
- move.l A0,A4
-
- moveq.l #0,D2 ; JOTD: this would help
-
- move.w LN_SIZE(A4),D2 ; # of items
- beq.b .exit ; JOTD: and this too
-
- add.l #LN_SIZE+2,A4
- .loop
- move.l (A4)+,A1 ; memory pointer
- move.l (A4)+,D0 ; memory size
- jsr (_LVOFreeMem,a6)
- subq.l #1,D2
- bne.b .loop
-
- .exit
- movem.l (A7)+,D1-A6
- rts
-
- _COPYMEM
- TST.L D0
- beq.b .EXIT
- CMP.L A0,A1
- BLS.S .ASCEND
- .DESCEND
- LEA.L (A0,D0.L),A0
- LEA.L (A1,D0.L),A1
- .LD MOVE.B -(A0),-(A1)
- SUBQ.L #1,D0
- BNE.S .LD
- RTS
-
- .ASCEND
- .LA MOVE.B (A0)+,(A1)+
- SUBQ.L #1,D0
- BNE.S .LA
- .EXIT
- RTS
-
- _COPYMEMQUICK
- tst.l D0
- beq.b .EXIT
- CMP.L A0,A1
- BLS.S .ASCEND
- .DESCEND
- LEA.L (A0,D0.L),A0
- LEA.L (A1,D0.L),A1
- .LD MOVE.L -(A0),-(A1)
- SUBQ.L #4,D0
- BNE.S .LD
- RTS
-
- .ASCEND
- .LA MOVE.L (A0)+,(A1)+
- SUBQ.L #4,D0
- BNE.S .LA
- .EXIT
- RTS
-
- ; FreeMem()
- ; < D0: size
- ; < A1: pointer
-
- _FreeMem:
- TST.L D0
- BNE.S .NOZERO
- RTS
-
- .NOZERO
- cmp.l #$BBBBBBBB,A1 ; temporary, Wings
- bne .sk
- rts
- .sk
- cmp.l #$1000000,D0 ; JOTD: safety, I had to switch off my amy
- bcc.b .FREEMFAIL ; when the value passed was too high (here >16MB)!
-
- CMP.L #ALLOCMTAB,A1 ; above ALLOCMTAB
- BHS.S .OK ; okay, try to free
- .FREEMFAIL
- EMUFAIL _LVOFreeMem,_execname
-
- .OK
- tst.l OSM_EXPMEM
- beq.b .FreeChip
-
- cmp.l OSM_EXPMEM,A1
- bcs.b .FreeChip ; below expansion memory -> chipmem
-
- ; fast memory - added by JOTD
-
- .FreeFast:
- move.l OSM_EXPMEM,A0 ; start of memory expansion
- add.l OSM_EXPSIZE,A0 ; size of memory expansion
-
- cmp.l A0,A1
- bcc.b .FREEMFAIL ; trying to free above memory expansion
-
- move.l OSM_EXPMEM,A0 ; start of memory table (fastmem)
- sub.l A0,A1 ; corrects offset on address !!
- bra.b .FreeGeneric ; removed by Harry
-
- ; chip memory - Harry's original
-
- .FreeChip:
- LEA.L ALLOCMTAB,A0 ; start of memory table (chipmem)
-
- .FreeGeneric:
- bsr GetAllocSem
-
- MOVEM.L D2/D3/A2/A3,-(A7)
- MOVE.L A1,D1
- ADDQ.L #7,D0
- AND.L #$FFFFFFF8,D1
- AND.L #$FFFFFFF8,D0
- BEQ.S .QU
- LSR.L #3,D0 ;# OF BITS TO CLEAR IN D0
-
- ;FREE MEM NOT ON A $40-BOUNDARY
- ;EVAL BEGINBYTE
- MOVE.L D1,D2
- LSR.L #6,D2
- LEA.L (A0,D2.L),A0
- MOVEM.L D1,-(A7)
- AND.L #$3F,D1
- BEQ.S .CNTCLR
- LSR.L #3,D1
- .2 BSET D1,(A0)
- ADDQ.L #1,D1
- ADDQ.L #8,(A7)
- SUBQ.L #1,D0
- BEQ.S .1
- CMP.L #8,D1
- BEQ.S .CNTCLR2
- BRA.S .2
-
- .1 MOVEM.L (A7)+,D1
- BRA.S .QU
-
- .CNTCLR2
- ADDQ.L #1,A0
- .CNTCLR
- MOVEM.L (A7)+,D1
-
- ;CLEAR $40-BOUNDARY-BYTES
- .3 CMP.L #8,D0
- BLO.S .CLREND
-
- ST (A0)+
- SUBQ.L #8,D0
- BRA.S .3
-
-
- .CLREND ;CLEAR END NOT ENDING ON A $40-
- TST.L D0 ;BOUNDARY
- BEQ.S .QU
- SUBQ.L #1,D0
- BSET D0,(A0)
- BRA.S .CLREND
-
- .QU MOVEM.L (A7)+,D2/D3/A2/A3
-
- bsr FreeAllocSem
- RTS
-
-
- ; < A1: memory pointer
- ; > D0: flags
-
- TYPEOFMEM:
- move.l A0,-(A7)
- moveq.l #0,D0
- cmp.l MaxLocMem(A6),A1
- bcs.b .chipmem
-
- move.l OSM_EXPMEM,A0
- cmp.l A0,A1
- bcs.b .exit ; not in chip and below expansion: unknown
-
- add.l OSM_EXPSIZE,A0
- cmp.l A0,A1
- bcc.b .exit ; not in chip and above expansion: unknown
-
- move.l #MEMF_FAST,D0
- bra.b .exit
-
- .chipmem
- cmp.l #$1000,A1
- bcs.b .exit
- move.l #MEMF_CHIP,D0
- .exit
- move.l (A7)+,A0
- rts
-
-
- ;>D0:SIZE
- ;>D1:CONDITIONS
- ;<D0:ADDY
-
- _AllocVec:
- move.l D2,-(A7)
- addq.l #$4,D0 ; adds bytes to store the size
- move.l D0,D2 ; saves size
-
- bsr _AllocMem
- tst.l D0
- beq.b .exit
-
- move.l D0,A0
- move.l D2,(A0) ; save size at start of block
-
- ; adds $4 to base address
-
- addq.l #$4,D0
- .exit:
- move.l (A7)+,D2
- rts
-
- ;>A1:Start of block
-
- _FreeVec:
- move.l -(A1),D0 ; gets block length
- JMPLIB FreeMem
-
- ;>D0:SIZE
- ;>D1:CONDITIONS
- ;<D0:ADDY
- ;LIMITATIONS:
- ; -MEMORY IS $40-ALIGNED (SOME BYTES WASTED)
- ; -MEMF_LARGEST IS IGNORED AS IN THE OS
- ; -ATM, ALSO MEMF_REVERSE IS IGNORED
-
- _AllocMem:
- tst.l d0
- beq .nomem ; not fatal anymore, allows broken programs to work
-
- MOVE.L D1,-(A7)
- and.l #~(MEMF_REVERSE!MEMF_LARGEST!MEMF_FAST!MEMF_CHIP!MEMF_CLEAR!MEMF_PUBLIC),(A7)+
- ;; bne .fail ; wrong flags
- ; removed (Test Drive II allocates memory with garbage in D1)
-
- btst #MEMB_CHIP,d1 ; chipmem required?
- BNE.S .NORMALCHIP
-
- ; JOTD: MEMB_CHIP not specified -> try to alloc fast
-
- movem.l D0/D1,-(A7)
- bsr.b .FMEM
- tst.l D0
- bne.b .fastok
- movem.l (A7)+,D0/D1
- bra.b .NORMALCHIP ; could not allocate fastmem: try chipmem
- .fastok:
- addq.l #8,A7
- rts
-
- .NORMALCHIP
- MOVEM.L D2-D5/A2/A3/A4,-(A7)
-
- addq.l #7,d0
- LSR.L #3,D0
- ;SEARCH SUFFICIENT BIG MEMAREA
-
- LEA.L ALLOCMTAB,A0 ;FIND A BYTE != 0 (FREE MEM)
- move.l ALLOCMTABSIZE,A3
- sub.l A4,A4
-
- .doalloc
- bsr AllocGeneric
-
-
- MOVEM.L (A7)+,D2-D5/A2/A3/A4
- tst.l D0
- RTS
-
- .FMEM:
- tst.l OSM_EXPMEM
- bne.b .ALLOCFAST ; expansion available: allocate
-
- ; no expansion: check if fast is required
-
- btst #MEMB_FAST,d1
- bne.b .nomem ; fastmem not available: error
-
- bra.b .NORMALCHIP ; no fast memory configured: try chipmem
-
- .ALLOCFAST
- MOVEM.L D2-D5/A2/A3/A4,-(A7)
- addq.l #7,d0
- LSR.L #3,D0
- ;SEARCH SUFFICIENT BIG MEMAREA
-
- move.l OSM_EXPMEM,A0 ;FIND A BYTE != 0 (FREE MEM)
- move.l ALLOCFASTMTABSIZE,A3
- move.l A0,A4 ; offset to add for ALLOCA
-
- bra .doalloc
-
- .nomem:
- moveq.l #0,D0
- rts
-
- .fail
- EXECFAIL _LVOAllocMem
-
- ; Added by JOTD to be used with chip and fast alloc
- ; < A0: alloc table
- ; < A3: end of alloc table
- ; < A4: offset to add to calculated address (0 for chip, OSM_EXPMEM for fast)
-
- AllocGeneric:
- bsr GetAllocSem
-
- MOVEQ.L #0,D4
- .2
- CMP.B #$FF,(A0)+
- BEQ.S .1
- ADD.L #$40,D4
- CMP.L A3,A0
- BNE.S .2
- BRA.S .ERR
- ;found free mem
- ;CHECK NOW SIZE
- .1 SUBQ.L #1,A0
- ;D4-BASE
- .3
- MOVE.L D0,-(A7) ;WANTED SIZE
- MOVE.L D4,-(A7) ;FOUND ADDRESS
-
- .6 TST.L D0
- BMI.S .CHKEND
- CMP.B #$FF,(A0)
- BNE.S .TOOSMALL
- ADDQ.L #1,A0 ;CHECK FOR EXCEEDING THE SIZE OF ALLOCMTAB
- ;MAY BE OMITTED SINCE ITS END CONTAINS $0
- ADD.L #$40,D4
- SUBQ.L #8,D0
- BEQ.S .CHKEND
- BRA.S .6
-
- .TOOSMALL ;LATER TODO: FIND EVENTUAL ZEROBITS
-
- ADDQ.L #4,A7 ;DISCARD D4 ON STACK
- MOVE.L (A7)+,D0
- ADDQ.L #1,A0
- ; AND.L #$FFFFFFC0,D4
- ADD.L #$40,D4
- BRA.S .2
-
- .CHKEND
- MOVE.L (A7)+,D4
- MOVE.L (A7)+,D0
- LSL.L #3,D0
- ;D0-SIZE
- ;D4-ABS
- ;MARK AREA AS USED
- MOVE.L D4,A1
- MOVE.L D0,D2
-
- add.l A4,A1 ; added by JOTD, offset for fastmem
- BSR.W PROTECTED_ALLOCA
- ;MEMORYSPACE ALREADY SUCESSFULLY
- ;CHECKED, RETURNCODE MAY BE IGNORED
-
- ; JOTD: check if MEMB_CLEAR is set, if not, don't clear memory
- ; (increases performance)
-
- btst #MEMB_CLEAR,D1
- beq.b .exit
-
- MOVE.L A1,A2
- ; MOVE.L D4,D2
- LSR.L #2,D2
-
- BRA.S .CLRM
-
- .CLRM1 CLR.L (A2)+
- .CLRM DBF D2,.CLRM1
- .exit
- bsr FreeAllocSem
- tst.l d0 ;some progs expect an correct set zero flag
- rts
- .ERR:
- moveq.l #0,D0 ; unable to allocate: table full
- bra.b .exit
-
- ; JOTD: semaphores needed for AllocMem/FreeMem/AllocAbs stuff
-
- GetAllocSem:
- tst.w _Multitasks
- beq.b .skip
- movem.l D0-D1/A0-A1,-(A7)
- JSRLIB Forbid
- movem.l (A7)+,D0-D1/A0-A1
- .skip
- rts
-
- FreeAllocSem:
- tst.w _Multitasks
- beq.b .skip
- movem.l D0-D1/A0-A1,-(A7)
- JSRLIB Permit
- movem.l (A7)+,D0-D1/A0-A1
- .skip
- rts
-
- ;RETURNS AT THE MOMENT ONLY THE SIZE OF THE LARGEST CHUNK-$1000 SAFETY
-
- _AvailMem:
- MOVEM.L A2/A3/D2/D3,-(A7)
- MOVE.L D1,D2
- AND.L #MEMF_FAST,D2
- BNE.S .FMEM
-
- ; check for chipmem available
-
- LEA.L ALLOCMTAB,A0
- move.l ALLOCMTABSIZE(pc),A3
-
- bsr GenericAvail
-
-
- .exit
- MOVEM.L (A7)+,A2/A3/D2/D3
- RTS
-
- .FMEM
- move.l OSM_EXPMEM,A0
- cmp.l #0,A0
- beq.b .nomem
- move.l ALLOCFASTMTABSIZE(pc),A3
-
- bsr GenericAvail
- bra.b .exit
-
- .nomem:
- moveq.l #0,D0
- bra.b .exit
-
- ; for chip & fast memory
-
- GenericAvail:
- MOVEQ.L #0,D2
- MOVEQ.L #0,D3
- .3 MOVE.B (A0)+,D0
- CMP.B #$FF,D0 ;SEARCH CHUNK
- BNE.S .1
- ADD.L #$40,D3
- BRA.S .2
-
- .1 CMP.L D2,D3 ;END OF CHUNK, COMPARE SIZE WITH
- BLO.S .4 ;PREVIOUS SIZE
- MOVE.L D3,D2 ;ACTUAL IS LARGER -> NEW LARGEST SIZE
- .4 MOVEQ.L #0,D3 ;RESET SIZE OF NEXT CHUNK
- .2 CMP.L A3,A0 ;UNTIL MEMORYTABLE EXCEEDED
- BLO.S .3
- cmp.l d2,d3
- blo .5
- move.l d3,d2
- .5
- CMP.L #$2000,D2
- BLO.S .6
- SUB.L #$1000,D2
- .6 MOVE.L D2,D0
- rts
-
- _AllocAbs:
- bsr GetAllocSem
- bsr PROTECTED_ALLOCA
- bsr FreeAllocSem
- tst.l D0
- rts
-
- PROTECTED_ALLOCA:
- tst.l OSM_EXPMEM
- beq.b .ALLOCA_CHIP ; no expansion: alloc chipmem
- cmp.l OSM_EXPMEM,A1
- bcc.b .ALLOCA_FAST ; above expansion: fast memory
- .ALLOCA_CHIP:
- movem.l A4,-(A7)
- LEA.L ALLOCMTAB,A4 ; chipmem alloc table
- bsr GenericAllocAbs
- movem.l (A7)+,A4
- move.l D0,A1
- rts
-
- .ALLOCA_FAST:
- movem.l A4,-(A7)
- move.l OSM_EXPMEM,A4 ; fastmem alloc table
- sub.l A4,A1 ; substracts expbase from the address
- bsr GenericAllocAbs ; the routine returns only offset
- add.l A4,D0 ; relative to memory block so we have to add expbase
- move.l D0,A1 ; A1=D0 for Harry!
- movem.l (A7)+,A4
- rts
-
- ; < A4: allocmtab (added by JOTD to be used by fastmem and chipmem)
-
-
- GenericAllocAbs
-
- MOVEM.L D1/D2/D3/A2/A3,-(A7)
- MOVE.L A7,A3 ; save stack
- MOVE.L _Slave(PC),A2
- MOVE.L A1,D2
- ADD.L D0,D2
- CMP.L A2,D2
- BHS.W .ERR
-
- move.l A1,D1
-
- ; ADDQ.L #7,D1
- AND.L #$FFFFFFF8,D1
- AND.L #$FFFFFFF8,D0
- BEQ.W .QU
- MOVEM.L D0/D1,-(A7)
-
- LSR.L #3,D0 ;# OF BITS TO CLEAR IN D0
-
- ;CHECK MEM NOT ON A $40-BOUNDARY
- ;EVAL BEGINBYTE
- MOVE.L D1,D2
- LSR.L #6,D2
- move.L A4,A0
- LEA.L (A0,D2.L),A0
- MOVEM.L D1,-(A7)
- AND.L #$3F,D1
- BEQ.S .CNTCHK
- LSR.L #3,D1
- .2 BTST D1,(A0)
- BEQ.W .ERR
- ADDQ.L #1,D1
- ; ADDQ.L #8,(A7)
- SUBQ.L #1,D0
- BEQ.S .1
- CMP.L #8,D1
- BEQ.S .CNTCHK2
- BRA.S .2
-
- .1 MOVEM.L (A7)+,D1
- BRA.S .CONT
-
- .CNTCHK2
- ADDQ.L #1,A0
- .CNTCHK
- MOVEM.L (A7)+,D1
-
- ;CLEAR $40-BOUNDARY-BYTES
- .3 CMP.L #8,D0
- BLO.S .CLREND
-
- CMP.B #$FF,(A0)+
- BNE.S .ERR
- SUBQ.L #8,D0
- BRA.S .3
-
-
- .CLREND
- TST.L D0
- BEQ.S .CONT
- SUBQ.L #1,D0
- BTST D0,(A0)
- BEQ.S .ERR
- BRA.S .CLREND
-
- .CONT MOVEM.L (A7)+,D0/D1
-
- ;ALLOC MEM
-
- LSR.L #3,D0 ;# OF BITS TO CLEAR IN D0
-
- ;MARK MEM NOT ON A $40-BOUNDARY
- ;EVAL BEGINBYTE
- MOVE.L D1,D2
- LSR.L #6,D2
- move.l A4,A0
- LEA.L (A0,D2.L),A0
- MOVEM.L D1,-(A7)
- AND.L #$3F,D1
- BEQ.S .CNTMARK
- LSR.L #3,D1
- .22 BCLR D1,(A0)
- ADDQ.L #1,D1
- ; ADDQ.L #8,(A7)
- SUBQ.L #1,D0
- BEQ.S .21
- CMP.L #8,D1
- BEQ.S .CNTMARK2
- BRA.S .22
-
- .21 MOVEM.L (A7)+,D1
- BRA.S .QU
-
- .CNTMARK2
- ADDQ.L #1,A0
- .CNTMARK
- MOVEM.L (A7)+,D1
-
- ;CLEAR $40-BOUNDARY-BYTES
- .23 CMP.L #8,D0
- BLO.S .MARKEND
-
- SF (A0)+
- SUBQ.L #8,D0
- BRA.S .23
-
-
- .MARKEND
- TST.L D0
- BEQ.S .QU
- SUBQ.L #1,D0
- BCLR D0,(A0)
- BRA.S .MARKEND
-
- .QU
-
- MOVE.L D1,D0
- .out
- MOVE.L A3,A7 ; restore stack
- MOVEM.L (A7)+,D1/D2/D3/A2/A3
- RTS
- .ERR2
- .ERR
- MOVEQ.L #0,D0
- bra.b .out
-
- ****************************************************************************
- * LIST HANDLING IN EXEC *
- ****************************************************************************
-
- ; Enqueue, was disabled, JOTD reactivated it
-
- _Enqueue ;a0=list a1=node
- MOVE.B (LN_PRI,A1),D1
- MOVE.L (LN_SUCC,A0),D0
- .1908 MOVE.L D0,A0
- MOVE.L (LN_SUCC,A0),D0
- BEQ.S .1914
- CMP.B (LN_PRI,A0),D1
- BLE.S .1908
- .1914 MOVE.L (LN_PRED,A0),D0
- MOVE.L A1,(LN_PRED,A0)
- MOVE.L A0,(LN_SUCC,A1)
- MOVE.L D0,(LN_PRED,A1)
- MOVE.L D0,A0
- MOVE.L A1,(LN_SUCC,A0)
- RTS
-
- ; FindPort
- ; < A1: name
- ; > D0: port
-
- _FINDPORT
- lea (PortList,A6),A0 ; system port list
- bra.s _FINDNAME
-
- _FINDNAME ;a0-list, a1-name, returns d0-node
- MOVEM.L A2,-(A7)
- MOVE.L A0,A2 ;find listheader (lords of war *grr*)
- .HSEARCH
- TST.L 4(A2)
- BEQ.S .HFOUND
- MOVE.L 4(A2),A2
- BRA.S .HSEARCH
-
- .HFOUND
- .LOOP TST.L (A2)
- BEQ.S .NOTFOUND
- MOVE.L (A2),A2
- MOVE.L LN_NAME(A2),A0
- BSR.W _strcmp
- TST.L D0
- BEQ.S .FOUND
- BRA.S .LOOP
-
- .FOUND MOVE.L A2,D0
- .exit
- MOVEM.L (A7)+,A2
- TST.L D0
- RTS
-
- .NOTFOUND
- MOVEQ.L #0,D0
- bra.b .exit
-
- _INSERT ;a0-list a1-node to be inserted a2-node after which to insert
- .HSEARCH
- TST.L 4(A0)
- BEQ.S .HFOUND
- MOVE.L 4(A0),A0
- BRA.S .HSEARCH
-
- .HFOUND
- MOVE.L A2,-(A7)
- TST.L (A7)+
- BEQ.S .ADDHEAD
- CMP.L A0,A2
- BEQ.S .ADDHEAD
- MOVE.L LH_TAILPRED(A0),-(A7)
- CMPM.L (A7)+,(A2)+ ;IF INSERTING AT END -> .ADDTAIL
- LEA.L -4(A2),A2
- BEQ.S .ADDTAIL
- MOVE.L (A2),A0 ;SUCCESSOR
- MOVE.L A1,(LN_PRED,A0) ;NEW PREDECESSOR
- MOVE.L (A2),(A1) ;SUCCESSOR IN ELEMENT TO BE INSERTED
- MOVE.L A2,(LN_PRED,A1) ;PREDECESSOR IN ELEMENT TO BE INSERTED
- MOVE.L A1,(A2) ;INSERTED NODE IS SUCCESSOR
- RTS
-
- .ADDTAIL
- MOVE.L (A2),(A1)
- MOVE.L A2,LN_PRED(A1)
- MOVE.L A1,LH_TAILPRED(A0)
- MOVE.L A1,(A2)
- RTS
-
- .ADDHEAD
- bra _ADDHEAD
-
- ; < A0: list
- ; > D0: node
- ; Uses commodore includes macro (exec/lists.i)
- _REMHEAD:
- movem.l A1,-(A7)
- REMHEAD
- movem.l (A7)+,A1
- RTS
-
- _ADDTAIL:
- movem.l D0/A0,-(A7)
- ADDTAIL
- movem.l (A7)+,D0/A0
- RTS
-
- _ADDHEAD:
- movem.l D0/A0,-(A7)
- ADDHEAD
- movem.l (A7)+,D0/A0
- RTS
-
-
- ; < A0: list
- ; > D0: node
- ; Uses commodore includes macro (exec/lists.i)
- _REMTAIL:
- movem.l A1,-(A7)
- REMTAIL
- movem.l (A7)+,A1
- RTS
-
- _REMOVE
- movem.l A0/A1,-(A7)
- REMOVE
- movem.l (A7)+,A0/A1
- RTS
-
- ifeq 1
- _ADDHEAD
- MOVE.L A2,-(A7)
- MOVE.L (A0),A2
- TST.L (A2)
- BEQ.S .EMPTYLIST
-
- MOVE.L (A0),A2
- MOVE.L A2,(A1)
- MOVE.L LN_PRED(A2),LN_PRED(A1)
- MOVE.L A1,LN_PRED(A2)
- MOVE.L A1,(A0)
- BRA.S .END
-
- .EMPTYLIST
- MOVE.L (A0),(A1)
- MOVE.L LH_TAILPRED(A0),LN_PRED(A1)
- MOVE.L A1,(A0) ;INSERT ELEMENT AS FIRST INTO *LIST
- MOVE.L A1,LH_TAILPRED(A0) ;ELEMENT IS ALSO LAST ONE
- .END MOVE.L (A7)+,A2
- RTS
-
- _ADDTAIL
- MOVE.L A2,-(A7)
- MOVE.L (A0),A2
- TST.L (A2)
- BEQ.S .EMPTYLIST
- MOVE.L LH_TAILPRED(A0),A2
-
- MOVE.L (A2),(A1)
- MOVE.L A2,LN_PRED(A1)
- MOVE.L A1,LH_TAILPRED(A0)
- MOVE.L A1,(A2)
- BRA.S .END
-
- .EMPTYLIST
- MOVE.L (A0),(A1)
- MOVE.L LH_TAILPRED(A0),LN_PRED(A1)
- MOVE.L A1,(A0) ;INSERT ELEMENT AS FIRST INTO *LIST
- MOVE.L A1,LH_TAILPRED(A0)
- .END MOVE.L (A7)+,A2
- RTS
-
- _REMOVE ;A1-NODE TO REMOVE
- MOVEM.L A2,-(A7)
- MOVE.L A1,A2
- .HSEARCH
- TST.L 4(A2)
- BEQ.S .HFOUND
- MOVE.L 4(A2),A2
- BRA.S .HSEARCH
-
- .HFOUND
- MOVE.L (A1),A0
- TST.L (A0)
- BEQ.S .REMTAIL
- CMP.L (A2),A1
- BEQ.S .REMHEAD
-
- MOVE.L LN_PRED(A1),A0
- MOVE.L (A1),(A0)
- MOVE.L (A1),A0
- MOVE.L LN_PRED(A1),LN_PRED(A0)
- .END MOVEM.L (A7)+,A2
- RTS
-
- .REMHEAD
- MOVE.L A2,A0
- BSR.S _REMHEAD
- BRA.S .END
-
- .REMTAIL
- MOVE.L A2,A0
- BSR.S _REMTAIL
- BRA.S .END
-
-
- ; < A0: list
- ; > D0: node
- _REMHEAD
- MOVE.L (A0),A1
- TST.L (A1)
- BEQ.S .EMPTYLIST
- MOVE.L A2,-(A7)
- MOVE.L (A0),A2
- MOVE.L A2,D0
- MOVE.L (A2),-(A7)
- TST.L (A7)+
- BEQ.S .SINGLEELEMENT
- MOVE.L LN_PRED(A2),D1
- MOVE.L (A2),A2
- MOVE.L D1,LN_PRED(A2)
- MOVE.L A2,(A0)
- MOVE.L (A7)+,A2
- RTS
-
- .SINGLEELEMENT
- MOVE.L (A0),A2
- MOVE.L (A2),(A0)
- MOVE.L LN_PRED(A2),LH_TAILPRED(A0)
- MOVE.L (A7)+,A2
- RTS
-
- .EMPTYLIST
- MOVEQ.L #0,D0
- RTS
-
- _REMTAIL
- MOVE.L (A0),A1
- TST.L (A1)
- BEQ.S .EMPTYLIST
- MOVE.L A2,-(A7)
- MOVE.L LH_TAILPRED(A0),A2
- MOVE.L (A2),-(A7)
- TST.L (A7)+
- BEQ.S .SINGLEELEMENT
- MOVE.L A2,D0
- MOVE.L (A2),D1
- MOVE.L LN_PRED(A2),A2
- MOVE.L D1,(A2)
- MOVE.L A2,LH_TAILPRED(A0)
- MOVE.L (A7)+,A2
- RTS
-
- .SINGLEELEMENT
- MOVE.L A2,D0
- MOVE.L (A2),(A0)
- MOVE.L LN_PRED(A2),LH_TAILPRED(A0)
- MOVE.L (A7)+,A2
- RTS
-
- .EMPTYLIST
- MOVEQ.L #0,D0
- RTS
- ENDIF
-
- ****************************************************************************
- * INTERRUPTPART IN EXEC *
- ****************************************************************************
-
- ; software interrupts (called when Cause() is called)
- ; not List-style because I don't need it right now
- ; Darkseed works OK with this
-
- INT_64:
- movem.l d0-d2/a0-a2/a5-a6,-(a7)
- move.w (_custom+intreqr),d0
- and.w #INTF_SOFTINT,d0
- beq .softint_end
-
- ;call handler/server
-
- move.l (4).W,a2
- lea (SoftInts,A2),A2 ; soft int
- moveq.l #4,D2
- .loop
- move.l (A2),D0
- beq.b .next
- move.l D0,A5
-
- move.B #NT_INTERRUPT,$0008(A5) ; acknowledge ?
-
- pea .cont(pc)
- MOVE.L ($12,A5),-(A7) ; code
- move.l ($E,A5),a1 ; data
- bsr InitInterruptRegs
- RTS ; call interrupt
- .cont
-
- .next
- lea ($10,A2),A2
- dbf D2,.loop
-
- .softint_end
- move.w #INTF_SOFTINT,(_custom+intreq)
- movem.l (a7)+,d0-d2/a0-a2/a5-a6
- rte
-
- INT_68 movem.l d0-d1/a0-a1/a5-a6,-(a7)
- move.w (_custom+intreqr),d0
- and.w #INTF_PORTS,d0
- beq.b .ports_end
-
- ;call handler/server
- .ports
- PEA .ports_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVPORTS+IV_CODE,A1),-(A7)
- move.l (IVPORTS+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .ports_cont
- .ports_end
- move.w #INTF_PORTS,(_custom+intreq)
- movem.l (a7)+,d0-d1/a0-a1/a5-a6
- rte
-
- ;---------------
-
- INT_6c:
- ; Level 3 interrupt
-
- ;;; movem.l d0-d1/a0-a1/a5-a6,-(a7)
- movem.l d0-a6,-(a7) ; save all registers
-
- ; JOTD: I put multitask switching at this level
-
- bsr HandleTaskSwitching
-
- ; continue level 3 interrupt
-
- move.w (_custom+intreqr),d0
- and.w #INTF_BLIT!INTF_COPER!INTF_VERTB,d0
- AND.W (_custom+intenar),d0
- beq .vertb_vend ; no interrupts
- btst #INTB_COPER,d0 ; copper interrupt?
- bne .vertb_copper
- btst #INTB_VERTB,d0 ; vertical blank interrupt?
- bne.b .vertb
-
- ; it's the blitter
-
- PEA .blt_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVBLIT+IV_CODE,A1),-(A7)
- move.l (IVBLIT+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
- .blt_cont
- ; acknowledge blitter interrupt
-
- move.w #INTF_BLIT,(_custom+intreq)
- bra.w .vertb_vend
-
- ; vertical blank
-
- .vertb
- bsr .reload_copper ; JOTD: moved this to copper interrupt, but
- ; this removed the display of Arcade Pool...
-
- ;read potinp value
-
- bsr ReadPotInp
- move.w D0,potinp_value
-
- ;store CIA-B timer value HI+LO
-
- bsr ReadTimerB
- move.w D0,VBL_TimerBValue
-
- ;timer++
-
- move.l microsec_vbl_interval,D0
- add.l D0,microsec_timer_vbl
- cmp.l #1000000,microsec_timer_vbl
- bcs.b .skip
-
- ; one more second in our lives...
-
- addq.l #1,sec_timer
- clr.l microsec_timer_vbl
- .skip
- ; stores microsec_timer_vbl value in another
- ; variable, so timer.device can update it
-
- move.l microsec_timer_vbl,microsec_timer
-
- ;set sprites
-
- move.l _gfxbase(pc),D0
- beq.b .ns
- move.l D0,A0
- tst.b (gb_SpriteReserved,a0)
- beq .ns
- lea (_sprites),a0
- lea (_custom+sprpt),a1
- moveq #7,d0
- .ss
- move.l (a0)+,d1
- bmi.b .skipspr
- move.l D1,(a1)
- .skipspr
- addq.l #4,A1
- dbf d0,.ss
- .ns
-
- ;call handler/server
- PEA .vertb_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVVERTB+IV_CODE,A1),-(A7)
- move.l (IVVERTB+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .vertb_cont
- ;input handler
- move.l _inputhandler(PC),d0
- beq .vertb_end
- moveq #$6c,d0
- bsr _InputHandlerVBI
- .vertb_end
- ; acknowledge vblank interrupt
-
- move.w #INTF_VERTB,(_custom+intreq)
-
- .vertb_vend
- movem.l (a7)+,d0-a6
- rte
-
- ; copper interrupt
-
- .vertb_copper
- ;set copperlist (this should be the first !)
-
- bsr .reload_copper
-
- ;call copperhandler/server
- PEA .vertb_cend(PC)
- move.l (4).W,a1
- MOVE.L (IVCOPER+IV_CODE,A1),-(A7)
- move.l (IVCOPER+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .vertb_cend
- ; acknowledge copper interrupt
-
- move.w #INTF_COPER,(_custom+intreq)
- bra.s .vertb_vend
-
- .reload_copper:
- move.l _gfxbase(PC),a0
- cmp.l #0,A0
- beq.b .skipcop
- move.l (gb_LOFlist,a0),D0
- beq.b .skipcop
- move.l D0,(_custom+cop2lc)
- move.l D0,OSM_COPLIST2
- .skipcop
- rts
-
-
- VBL_TimerBValue:
- dc.w 0
-
- ; reads RMB/2nd joystick button
- ; only if lowlevel is open or an input handler is installed
-
- ReadPotInp:
- tst.l _lowlbase
- bne.b .dotest
- tst.l _inputhandler
- bne.b .dotest
- rts
- .dotest
- move.w potinp+_custom,D0
- btst #14,D0
- beq.b .reset
- btst #6,D0
- bne.b .noreset
- .reset
- move.w #$CC01,(potgo+_custom) ; reset ports
- .noreset
- rts
-
- ; < D0: timer value
- ReadTimerB:
- movem.l D1/D2,-(A7)
- sub.w D1,D1
- sub.w D2,D2
-
- move.b $BFE601,D1 ; read LSB
- move.b $BFE701,D0 ; read MSB
- move.b $BFE601,D2 ; read LSB again
-
- cmp.w D1,D2
- bcc.b .cycle ; D2 passed from $0x to $Fx or something like that
- .exit:
- lsl.w #8,D0
- or.b D1,D0
- movem.l (A7)+,D1/D2
- rts
- .cycle:
- subq.b #1,D0
- bra.b .exit
-
- ;---------------
-
- INT_70 movem.l d0-d1/D6/a0-a1/a5-a6,-(a7)
- move.w (_custom+intreqr),d6
- AND.W (_custom+intenar),d6
- and.w #INTF_AUD0!INTF_AUD1!INTF_AUD2!INTF_AUD3,d6
- BTST #7,D6
- BEQ.S .AUD1
-
- ;call handler/server
- move.l #$80,d1
- PEA .aud0_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVAUD0+IV_CODE,A1),-(A7)
- move.l (IVAUD0+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .aud0_cont move.w #INTF_AUD0,(_custom+intreq)
- BCLR #7,D6
-
- .AUD1 BTST #8,D6
- BEQ.S .AUD2
-
- ;call handler/server
- move.l #$100,d1
- PEA .aud1_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVAUD1+IV_CODE,A1),-(A7)
- move.l (IVAUD1+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .aud1_cont MOVE.W #INTF_AUD1,(_custom+intreq)
- BCLR #8,D6
-
- .AUD2 BTST #9,D6
- BEQ.S .AUD3
-
- ;call handler/server
- move.l #$200,d1
- PEA .aud2_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVAUD2+IV_CODE,A1),-(A7)
- move.l (IVAUD2+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .aud2_cont MOVE.W #INTF_AUD2,(_custom+intreq)
- BCLR #9,D6
-
- .AUD3 BTST #$A,D6
- BEQ.S .aud_end
-
- ;call handler/server
- move.l #$400,d1
- PEA .aud3_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVAUD3+IV_CODE,A1),-(A7)
- move.l (IVAUD3+IV_DATA,a1),a1
- bsr InitInterruptRegs
- RTS
-
- .aud3_cont MOVE.W #INTF_AUD3,(_custom+intreq)
- BCLR #$A,D6
-
- .aud_end movem.l (a7)+,d0-d1/D6/a0-a1/a5-a6
- rte
-
- INTSERVNODE_AUDIO0
- dc.l 0 ;LN_SUCC
- dc.l 0 ;LN_PRED
- dc.b NT_INTERRUPT ;LN_TYPE
- dc.b 120 ;LN_PRI
- dc.l 0 ;LN_NAME
- dc.l 0 ;IS_DATA
- dc.l _AUD0_CODE ;IS_CODE
-
- INTSERVNODE_AUDIO1
- dc.l 0 ;LN_SUCC
- dc.l 0 ;LN_PRED
- dc.b NT_INTERRUPT ;LN_TYPE
- dc.b 120 ;LN_PRI
- dc.l 0 ;LN_NAME
- dc.l 0 ;IS_DATA
- dc.l _AUD1_CODE ;IS_CODE
-
- INTSERVNODE_AUDIO2
- dc.l 0 ;LN_SUCC
- dc.l 0 ;LN_PRED
- dc.b NT_INTERRUPT ;LN_TYPE
- dc.b 120 ;LN_PRI
- dc.l 0 ;LN_NAME
- dc.l 0 ;IS_DATA
- dc.l _AUD2_CODE ;IS_CODE
-
- INTSERVNODE_AUDIO3
- dc.l 0 ;LN_SUCC
- dc.l 0 ;LN_PRED
- dc.b NT_INTERRUPT ;LN_TYPE
- dc.b 120 ;LN_PRI
- dc.l 0 ;LN_NAME
- dc.l 0 ;IS_DATA
- dc.l _AUD3_CODE ;IS_CODE
-
- _AUD0_CODE
- _AUD1_CODE
- _AUD2_CODE
- _AUD3_CODE
- RTS
-
- InitInterruptRegs:
- lea _custom,A0 ; added by Jeff
- move.l $4.W,A6
- move.w (intenar,A0),D0
- and.w (intreqr,A0),D0
- rts
-
- ;---------------
-
- INT_78 movem.l d0-d1/a0-a1/a5-a6,-(a7)
- move.w (_custom+intreqr),d0
- and.w #INTF_EXTER,d0
- beq .exter_end
-
- ;call handler/server
- .exter PEA .exter_cont(PC)
- move.l (4).W,a1
- MOVE.L (IVEXTER+IV_CODE,A1),-(A7)
- move.l (IVEXTER+IV_DATA,a1),a1
- RTS
- .exter_cont
- .exter_end
- move.w #INTF_EXTER,(_custom+intreq)
- movem.l (a7)+,d0-d1/a0-a1/a5-a6
- rte
-
-
- ;---------------
-
- INT_SERVER
- move.l (IV_NODE,a1),-(a7)
- .loop move.l (a7),d0
- beq .end
- move.l d0,a0
- move.l (LN_SUCC,a0),(a7)
- move.l (IS_DATA,a0),a1
- TST.L (IS_CODE,A0)
- BEQ.S .loop
- move.l (IS_CODE,a0),a6
- pea (.loop)
- lea (_custom),a0 ;some require this
- jmp (a6)
- .end addq.l #4,a7
- rts
-
-
- ; Cause, added by JOTD
- ; ripped from ROM and commented (so Harry is happy :))
- ; < A1: Interrupt
-
-
- _Cause:
- DISABLE
-
- MOVEQ #NT_SOFTINT,D0
- CMP.B $0008(A1),D0
- BEQ.B .LB_181A ; already softint, go out
- MOVE.B D0,LN_TYPE(A1) ; sets to soft int type
- MOVE.B LN_PRI(A1),D0
- AND.W #$00F0,D0 ; masks cos' only -32,-16,0,16,32 are supported
- EXT.W D0
- LEA $01D2(A6),A0 ; SOFTINT2
- ADDA.W D0,A0 ; -32: offset 0, -16: offset 1 and so on...
- MOVE.L A1,(A0) ; not exact but who cares ATM...
-
- MOVE.W #$8004,$00DFF09C ; interrupt requested
- BSET #$05,$0124(A6)
- .LB_181A
-
- SUBQ.B #1,$0126(A6) ; enable
- BGE.B .LB_1828
- MOVE.W #$C004,$00DFF09A ; + allow level 1 interrupt
- .LB_1828
- NOP
- RTS
-
-
- IFD XXXXXXXXX
- _RealCause:
- DISABLE
-
- MOVEQ #$0B,D0
- CMP.B $0008(A1),D0
- BEQ.B .LB_181A ; already softint, go out
- MOVE.B D0,LN_TYPE(A1) ; sets to soft int type
- MOVE.B LN_PRI(A1),D0
- AND.W #$00F0,D0 ; masks cos' only -32,-16,0,16,32 are supported
- EXT.W D0
- LEA $01D2(A6),A0 ; SOFTINT2
- ADDA.W D0,A0 ; -32: offset 0, -16: offset 1 and so on...
- ADDQ.L #4,A0 ; tail of list
- MOVE.L $0004(A0),D0 ; tailpred
- MOVE.L A1,$0004(A0) ; sets current interrupt in tailpred
- EXG D0,A0
- MOVEM.L D0/A0,(A1)
- MOVE.L A1,(A0) ; ends linking interrupt in the softint list
- MOVE.W #$8004,$00DFF09C ; interrupt requested
- BSET #$05,$0124(A6)
- .LB_181A
-
- ENABLE
- NOP
- RTS
- ENDC
-
-
- ; set int vector, replaced old Harry code by direct 3.1 ROM rip (JOTD)
- ; with a test against $DDDDDDDD value
- ; (original ROM sets to 0 the default interrupt memory I think, but OSEmu
- ; prefers to trash this zone to avoid bugs)
-
- _SETINTVECTOR: ;D0-INT#, A1-INTERRUPTNODE, RET D0-OLD INTERRUPTNODE
- tst.l D0
- beq.b .tbe_ok
- CMP.L #$4,D0
- BLO.S .NOTSUPPORTED
- CMP.L #$C,D0
- BHS.S .NOTSUPPORTED
-
-
- .tbe_ok
- MULU.W #$000C,D0
- LEA $54(A6,D0.W),A0
- DISABLE
- MOVE.L $0008(A0),D0
- MOVE.L A1,$0008(A0)
- BEQ.B .LB_16AA
-
- cmp.l #VAL_DDDDDDDD,A1 ; added
- BEQ.B .LB_16AA ; added
-
- MOVE.L $000E(A1),(A0)
- MOVE.L $0012(A1),$0004(A0)
- BRA.B .LB_16B2
- .LB_16AA
- MOVEQ #-$01,D1
- MOVE.L D1,(A0)
- MOVE.L D1,$0004(A0)
- .LB_16B2
- ENABLE
- .ignore
- RTS
-
- .NOTSUPPORTED
- pea _LVOSetIntVector
- pea _execname
- bra _emufail
-
-
-
- ;d0=intnumber a1=interrupt
-
- _AddIntServer:
- movem.l d6/a2-a4,-(a7)
- move.l d0,d6 ; save interrupt number for later use
- mulu #IV_SIZE,D0
- lea (IntVects+IV_NODE,a6,d0.l),a2 ;a2 = list base
- move.w #INTF_INTEN,(_custom+intena)
-
- move.b (LN_PRI,a1),d1 ;d1 = priority
- sub.l a3,a3 ;a3 = predecessor
- move.l (a2),a4 ;a4 = successor
-
- .next move.l a4,d0
- beq .hangin
- cmp.b (LN_PRI,a4),d1
- bgt .hangin
- move.l a4,a3
- move.l (LN_SUCC,a3),a4
- bra .next
-
- .hangin move.l a3,(LN_PRED,a1)
- bne .hi1
- move.l a2,a3 ;LN_SUCC == 0 !...
- .hi1 move.l a1,(LN_SUCC,a3)
- move.l a4,(LN_SUCC,a1)
- beq .hi2
- move.l a1,(LN_PRED,a4)
- .hi2
- .end move.w #INTF_SETCLR!INTF_INTEN,d0 ; JOTD: added specific interrupt
- bset d6,d0
- move.w d0,(_custom+intena) ; enable for DreamWeb. See RKRM!
- movem.l (a7)+,a2-a4/d6
- rts
-
- ifeq 1
- MOVE.L D2,-(A7)
- MOVE.L D0,D2
- MOVE.L D0,D1
- MULU.W #IV_SIZE,D0
- LEA (IntVects,A6,D0.W),A0
- MOVE.L (A0),A0
- MOVE.W #INTF_INTEN,(_custom+intena)
- ADDQ.B #1,(IDNestCnt,A6)
- BSR.W _Enqueue
- MOVE.W #-$8000,D0
- BSET D2,D0
- MOVE.W D0,(_custom+intena)
- SUBQ.B #1,(IDNestCnt,A6)
- BGE.S .1654
- MOVE.W #INTF_SETCLR!INTF_INTEN,(_custom+intena)
- .1654 MOVE.L (A7)+,D2
- RTS
- endc
-
- _RemIntServer ;d0=intnumber a1=interrupt
-
- ;this is a workaround for Millenium2·2, which does not set D0 correctly
- cmp.l #$20,d0
- blo .ok
- moveq #5,d0
- .ok
- movem.l a2-a4,-(a7)
- mulu #IV_SIZE,D0
- lea (IntVects+IV_NODE,a6,d0.l),a2 ;a2 = list base
- move.w #INTF_INTEN,(_custom+intena)
-
- sub.l a3,a3 ;a3 = predecessor
- move.l a2,a0
-
- .next move.l (LN_SUCC,a0),a0
- cmp.l a0,a1
- beq .hangout
- move.l a0,a3
- bra .next
-
- .hangout move.l (LN_SUCC,a1),a4 ;a4 = successor
- move.l a4,d0
- beq .ho1
- move.l a3,(LN_PRED,a4)
- .ho1 move.l a3,d0
- bne .ho2
- move.l a2,a3 ;LN_SUCC == 0 !...
- .ho2 move.l a4,(LN_SUCC,a3)
-
- .end move.w #INTF_SETCLR!INTF_INTEN,(_custom+intena)
- movem.l (a7)+,a2-a4
- rts
-
- _ExitIntr MOVEM.L (A7)+,D0-D1/A0-A1/A5-A6
- RTE
-
- **************************************************************************
- * LIBRARY FUNCTIONS *
- **************************************************************************
-
- OPENLIB:
- move.l a2,-(a7)
-
- lea _libtable,a2
- .next move.l (a2)+,a0
- move.l a0,d0
- beq .err
- bsr _strcmp
- beq .found
- addq.l #4,a2
- bra .next
-
- .found move.l (a2),a0
- jsr (a0) ;init
-
- move.l (a7)+,a2
- rts
-
- .err
- EMUFAIL _LVOOpenLibrary,_execname
-
- **************************************************************************
- * DEVICE FUNCTIONS *
- **************************************************************************
-
- ;a0=name d0=unit a1=ioreq d1=flags
-
- _OpenDevice:
- moveM.l D0/A0-a2,-(a7)
-
- MOVE.L A0,A1
- lea _devtable,a2
- .next move.l (a2)+,a0
- move.l a0,d0
- beq .err
- bsr _strcmp
- beq .found
- addq.l #4,a2
- bra .next
-
- .err
- EMUFAIL _LVOOpenDevice,_execname
-
- .found
-
- MOVE.L 8(A7),A1
- IFNE CORRECTDEVICES
- MOVE.L (A2),(IO_DEVICE,A1)
- ELSE
- move.l A2,-(A7)
- lea .namebuf(pc),A2
- move.b (A0)+,(A2)
- move.b (A0)+,(1,A2)
- move.b (A0)+,(2,A2)
- move.b (A0)+,(3,A2)
- move.l A2,A0 ; now the name in A0 is word aligned
- move.l (A7)+,A2
- move.l (a0),(IO_DEVICE,a1)
- ENDC
- move.l (A7),(IO_UNIT,a1)
- move.b d1,(IO_FLAGS,A1)
- MOVEM.L (A7)+,D0/A0-A2
- moveq #0,d0
- move.b d0,(IO_ERROR,a1)
- rts
-
- .namebuf
- dc.l 0
-
- _InputHandlerVBI
- ;check LMB
- btst #CIAB_GAMEPORT0,(_ciaa+ciapra) ; mouse left button?
- seq d0
- cmp.b (_last_lmb),d0
- beq .lmbend ; same state as before
- move.b d0,(_last_lmb)
- lea _inputevent,a0
- clr.l (ie_NextEvent,a0)
- move.b #IECLASS_RAWMOUSE,(ie_Class,a0)
- clr.b (ie_SubClass,a0)
- move.w #IECODE_LBUTTON,(ie_Code,a0)
- tst.b d0
- bne .lmb1
- or.w #IECODE_UP_PREFIX,(ie_Code,a0)
- .lmb1 moveq #0,d0
- move.b (_last_lmb),d1
- beq .lmb2
- or.w #IEQUALIFIER_LEFTBUTTON,d0
- .lmb2 move.b (_last_rmb),d1
- beq .lmb3
- or.w #IEQUALIFIER_RBUTTON,d0
- .lmb3 move.w d0,(ie_Qualifier,a0)
- pea .lmbend(pc)
- move.l _inputhandler,a1
- move.l (IS_CODE,a1),-(a7)
- move.l (IS_DATA,a1),a1
- rts ;a0=InputEvent a1=HandlerData
- .lmbend
- ;check RMB
- ; btst #POTGOB_DATLY-8,(_custom+potinp)
- btst #POTGOB_DATLY-8,potinp_value
- seq d0
- cmp.b (_last_rmb),d0
- beq .rmbend
- move.b d0,(_last_rmb)
- lea _inputevent,a0
- clr.l (ie_NextEvent,a0)
- move.b #IECLASS_RAWMOUSE,(ie_Class,a0)
- clr.b (ie_SubClass,a0)
- move.w #IECODE_RBUTTON,(ie_Code,a0)
- tst.b d0
- bne .rmb1
- or.w #IECODE_UP_PREFIX,(ie_Code,a0)
- .rmb1 moveq #0,d0
- move.b (_last_lmb),d1
- beq .rmb2
- or.w #IEQUALIFIER_LEFTBUTTON,d0
- .rmb2 move.b (_last_rmb),d1
- beq .rmb3
- or.w #IEQUALIFIER_RBUTTON,d0
- .rmb3 move.w d0,(ie_Qualifier,a0)
- pea .rmbend
- move.l _inputhandler,a1
- move.l (IS_CODE,a1),-(a7)
- move.l (IS_DATA,a1),a1
- rts ;a0=InputEvent a1=HandlerData
- .rmbend
- ;check MouseMove
- move.w (_custom+joy0dat),d0
- move.w (_last_joy0dat),d1
- cmp.w d0,d1
- beq .rts ; no move
- move.w d0,(_last_joy0dat) ; save joy0dat
- lea _inputevent,a0
- clr.l (ie_NextEvent,a0)
- move.b #IECLASS_RAWMOUSE,(ie_Class,a0)
- clr.b (ie_SubClass,a0)
- move.w #IECODE_NOBUTTON,(ie_Code,a0)
- clr.w (ie_Qualifier,a0)
- movem.l d2-d3,-(a7)
- moveq #0,d2
- move.b d1,d2
- moveq #0,d3
- move.b d0,d3
- sub.w d2,d3 ; newdat-olddat
- cmp.w #127,d3
- bgt .xsub
- cmp.w #-128,d3
- bge .xok
- add.w #512,d3
- .xsub sub.w #256,d3
- .xok move.w d3,(ie_X,a0)
- movem.l (a7)+,d2-d3
- lsr.w #8,d0
- lsr.w #8,d1
- sub.w d1,d0
- cmp.w #127,d0
- bgt .ysub
- cmp.w #-128,d0
- bge .yok
- add.w #512,d0
- .ysub sub.w #256,d0
- .yok move.w d0,(ie_Y,a0)
- move.l _inputhandler,a1
- move.l (IS_CODE,a1),-(a7)
- move.l (IS_DATA,a1),a1
- .rts rts ;a0=InputEvent a1=HandlerData
-
- _InputHandlerPI:
- lea _inputevent,a0
- clr.l (ie_NextEvent,a0) ; only one event at a time!
- move.b #IECLASS_RAWKEY,(ie_Class,a0)
- clr.b (ie_SubClass,a0)
- moveq #0,d0
- move.b (KBDQUALIFIER+1),d0
- move.w d0,(ie_Code,a0)
-
- moveq #0,d0
- move.b (KBDQUALIFIER),d0
- move.w D0,(ie_Qualifier,a0)
- move.l _inputhandler,a1
- move.l (IS_CODE,a1),-(a7)
- move.l (IS_DATA,a1),a1
- rts ;a0=InputEvent a1=HandlerData
-
- _SendIO
- _DoIO ;a1=ioreq
- tst.l (IO_DEVICE,A1)
- beq .cd ; not found: ignore! (JOTD)
-
- move.w (IO_COMMAND,a1),d0 ;d0=command
- IFNE CORRECTDEVICES
- MOVE.L _tddevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"trac",(IO_DEVICE,a1)
- ENDC
- beq .trackdisk
- IFNE CORRECTDEVICES
- MOVE.L _inpdevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"inpu",(IO_DEVICE,a1)
- ENDC
- beq .input
-
- ; cd.device added by Jeff
-
- IFNE CORRECTDEVICES
- MOVE.L _cddevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"cd.d",(IO_DEVICE,a1)
- ENDC
- beq .cd
-
- ; cdtv.device added by Jeff
-
- IFNE CORRECTDEVICES
- MOVE.L _cdtvdevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"cdtv",(IO_DEVICE,a1)
- ENDC
- beq .cd
-
- ; keyboard.device added by Jeff
-
- IFNE CORRECTDEVICES
- MOVE.L _kbdevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"keyb",(IO_DEVICE,a1)
- ENDC
- beq .keyboard
-
-
- ; timer.device added by Jeff
-
- IFNE CORRECTDEVICES
- MOVE.L _timerdevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"time",(IO_DEVICE,a1)
- ENDC
- beq .timer
-
- .fail
- move.l D0,D6
-
- EMUFAIL _LVODoIO,_execname
-
- .cd
- moveq.l #0,D0 ; cd.device,cdtv.device: do nothing
- rts
-
- ; DoIO on timer.device, added by JOTD
-
- .timer
- move.l ($18,A1),D0
- cmp.l #UNIT_MICROHZ,D0
- beq .ok
- cmp.l #UNIT_VBLANK,D0
- beq .ok
-
- ; UNIT_ECLOCK,UNIT_WAITUNTIL,UNIT_WAITECLOCK not supported yet
-
- bra.b .fail ; timer device not supported yet, too bad
- rts
-
- ; can be VBLANK or MICROHZ
- .ok
- move.w (IO_COMMAND,A1),D1
- cmp.w #TR_GETSYSTIME,D1
- bne.b .fail
-
- ; system time requested
- ; (valable for PAL/NTSC)
-
- move.l sec_timer,D1
- move.l D1,(TV_SECS+IO_SIZE,A1) ; seconds computed OK, now microsecs...
-
- move.l microsec_timer,D1
-
- cmp.l #UNIT_MICROHZ,($18,A1)
- bne.b .endcia
-
- ; UNIT_MICROHZ, we need to be more accurate
-
- bsr ReadTimerB
- move.l D2,-(A7)
- move.w D0,D2 ; new value
- sub.w VBL_TimerBValue,D0
- move.w D2,VBL_TimerBValue ; update value
- move.l (a7)+,D2
- tst.w D0
- bpl.b .positive
- neg.w D0 ; take absolute value
- .positive
-
- ; we need to *1.4... to compute the real number of microsecs
- ; we do better: multiplicate by approx (1000000*0x100)/0xAD303
- ; and then shift right by 16 bits
-
- mulu #361,D0
- lsr.l #8,D0
- add.l D0,D1 ; adds to microsecs computed from VBL interrupt
-
- move.l D1,microsec_timer ; update microsec timer for better accurracy
-
- .endcia
-
- move.l D1,(TV_MICRO+IO_SIZE,A1)
- moveq.l #0,D0
- clr.b (IO_ERROR,A1)
- rts
-
- .keyboard
- cmp.w #KBD_READMATRIX,d0
- beq .kb_readmatrix
- cmp.w #KBD_READEVENT,d0
- beq .kb_readevent
-
-
- cmp.w #CMD_CLEAR,d0
-
- BRA .fail
-
- ; read event (Black Tiger)
-
- .kb_readevent
- movem.l A1,-(A7)
- lea _inputevent(pc),A0
- move.l (IO_DATA,a1),a1
- move.w #$15,D0
- .kbcopy
- move.b (A0)+,(A1)+
- dbf D0,.kbcopy
- movem.l (A7)+,A1
- bra .kbend
-
- .kb_readmatrix
- move.l a1,-(SP)
- moveq #15,d0
- move.l (IO_LENGTH,a1),d1
- move.l (IO_DATA,a1),a0
- cmp.l d0,d1
- bls.s .lower
- move.w d0,d1
- .lower
- move.l d1,(IO_ACTUAL,a1)
- move.l (IO_DEVICE,a1),a1
- lea $136(a1),a1
- bra.s .goto
- .loop
- move.b (a1)+,(a0)+
- .goto
- dbra d1,.loop
- movea.l (SP)+,a1
- .kbend
- clr.b (IO_ERROR,a1)
- moveq.l #0,d0
- rts
-
- .input cmp.w #CMD_RESET,d0
- beq .ret
- cmp.w #IND_ADDHANDLER,d0
- beq .i_addh
- cmp.w #IND_REMHANDLER,d0
- beq .i_remh
- cmp.w #IND_SETMPORT,d0
- beq .ret
- cmp.w #IND_SETMTRIG,d0
- beq .i_setmtrig
- BRA .fail
-
- ; adds an input handler
- .i_addh move.w (_custom+joy0dat),(_last_joy0dat)
-
- move.l A0,-(A7)
-
- tst.l _inputhandler
- BEQ .add
-
- ; already an handler installed!
-
- move.l _inputhandler,A0
-
- ; check if intuition handler is installed
-
- cmp.l #IntuitionInputHandler,(IS_CODE,A0)
- bne.b .fail
-
- move.l (IO_DATA,a1),_inputhandler ; sets handler
- bsr rem_input_handler ; removes intuition input handler
- .add
- move.l (IO_DATA,a1),_inputhandler
- move.l (A7)+,A0
- moveq.l #0,D0 ; added by JOTD
- rts
-
- .i_remh clr.l _inputhandler
- rts
- .i_setmtrig move.l (IO_DATA,a1),.gpt
- moveq.l #0,D0 ; added by JOTD
- rts
- .gpt dc.l 0
-
- .trackdisk
- cmp.w #CMD_READ,d0
- beq .td_read
- cmp.w #CMD_CLEAR,d0
- beq .ret
- cmp.w #ETD_READ,d0
- beq .td_read
- cmp.w #TD_MOTOR,d0
- beq .ret
- cmp.w #TD_FORMAT,d0
- beq .td_write
- cmp.w #TD_REMOVE,d0
- beq .ret
- cmp.w #TD_CHANGENUM,d0
- beq .ret
- cmp.w #TD_CHANGESTATE,d0
- beq .ret
- cmp.w #ETD_SEEK,d0
- beq .td_seek ; added by JOTD
- cmp.w #TD_SEEK,d0
- beq .td_seek ; added by JOTD
- cmp.w #ETD_WRITE,d0
- beq .td_write
- cmp.w #CMD_WRITE,d0
- beq .td_write ; added by JOTD
- cmp.w #ETD_UPDATE,d0
- beq .ret
- cmp.w #ETD_CLEAR,d0
- beq .ret
- cmp.w #ETD_MOTOR,d0
- beq .ret
- cmp.w #CMD_UPDATE,d0 ; added by JOTD
- beq .ret
- BRA.W .fail
-
- .td_seek: ; seek only moves the heads, nothing is read!
- beq .ret
-
- ;"deuteros" expects that a1 is unchanged !
- .td_read movem.l d2/a1,-(a7)
- move.l (IO_OFFSET,a1),d0
- move.l (IO_LENGTH,a1),d1
- move.l d1,(IO_ACTUAL,a1) ; Mr.Larmer
- move.l (IO_UNIT,a1),d2
- addq.l #1,d2
- move.l (IO_DATA,a1),a0
- move.l (_RESLOAD),a1
- jsr (resload_DiskLoad,a1)
- movem.l (a7)+,d2/a1
- .ret clr.b (IO_ERROR,a1)
- moveq.l #0,D0 ; added by JOTD
- rts
-
- .td_write tst.l _p3 ; JOTD: what's this ??? WHDLoad registered protection?
- bne.b .td_dowrite
- .td_dowrite
- movem.l a1-a2,-(a7)
- clr.b (IO_ERROR,a1)
- move.l (IO_LENGTH,a1),d0 ;size
- lea (.disk),a0
- move.l (IO_UNIT,a1),d1
- add.b #"1",d1
- move.b d1,(5,a0) ;name
- move.l (IO_OFFSET,a1),d1 ;offset
- move.l (IO_DATA,a1),a1 ;address
- move.l (_RESLOAD),a2
- jsr (resload_SaveFileOffset,a2)
- movem.l (a7)+,a1-a2
- rts
- .f st (IO_ERROR,a1)
- rts
-
- .disk dc.b "Disk.",0,0,0
-
- _SENDAUDIO
- CLR.B IO_ERROR(A1)
- MOVEQ.L #0,D0
- RTS
-
- _WAITIO
- IFNE CORRECTDEVICES
- MOVE.L _cddevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"cd.d",(IO_DEVICE,a1)
- ENDC
- beq .cd
-
- IFNE CORRECTDEVICES
- MOVE.L _cdtvdevtable+4(PC),D1
- CMP.L (IO_DEVICE,A1),D1
- ELSE
- cmp.l #"cdtv",(IO_DEVICE,a1)
- ENDC
- beq .cd
-
- ;;.fail
- ;; EMUFAIL _LVOWaitIO,_execname
-
- .cd
- CLR.B IO_ERROR(A1)
- moveq.l #0,D0 ; cd.device,cdtv.device: do nothing
- RTS
-
- _ABORTIO
- CLR.B IO_ERROR(A1)
- MOVEQ.L #0,D0
- RTS
-
- _CHECKIO
- MOVE.L A1,D0 ; request has completed
- RTS
-
-
- INTSERVNODE_SP dc.l 0 ;LN_SUCC
- dc.l 0 ;LN_PRED
- dc.b NT_INTERRUPT ;LN_TYPE
- dc.b 0 ;LN_PRI
- dc.l 0 ;LN_NAME
- dc.l DATA_KBD ;IS_DATA
- dc.l INT_KBD ;IS_CODE
-
- DATA_KBD ds.b $1C0
-
- INT_KBD
- movem.l D2-D4/A6,-(SP)
- movea.l A1,A6
- moveq #0,D2
- move.b $BFEC01,D2
-
- MOVE.B #$41,$BFEE01
-
- ; ori.b #$40,$BFEE01
-
- ; acknowledge keyboard
-
- MOVEQ.L #2,D3
- .4 MOVE.L D1,-(A7)
- MOVE.B $DFF006,D1
- .3 CMP.B $DFF006,D1
- BEQ.S .3
- MOVE.L (A7)+,D1
- DBF D3,.4
-
- moveq #0,D4
- not.b D2
- ror.b #1,D2
-
- ; keyboard is read here
-
- MOVE.B D2,KBDQUALIFIER+1
-
-
- cmpi.b #$78,D2
- bne.s lbC000078
-
- illegal ; should not happen
-
- ifeq 1
- bset #0,$134(A6)
- beq.s lbC00007E
- bset #1,$134(A6)
- bne.w lbC00012E
- movea.l $124(A6),A1
- tst.l (A1)
- beq.w lbC00012C
- lbC00005E
- move.l (A1),D3
- beq.w lbC00012E
- addq.w #1,$132(A6)
- move.l A6,-(SP)
- movea.l $24(A6),A6
- jsr -$B4(A6)
- movea.l (SP)+,A6
- movea.l D3,A1
- bra.s lbC00005E
- endc
-
-
- lbC000078
-
- bclr #0,$134(A6)
- lbC00007E
- move.w D2,D1
- andi.w #$7F,D1
-
- ; Jff: read shift/ctrl/alt keys
-
- bsr _SetQualifierFlags
-
- cmpi.w #$71,D1
- bhi.w lbC0000EA
-
- move.w D1,D0
- andi.w #7,D0
- lsr.w #3,D1
- lea $136(A6),A0
- btst #7,D2
- bne.s lbC0000AE
- bset D0,0(A0,D1.W)
- cmpi.w #12,D1
- bne.s lbC0000CE
- bset D0,$135(A6)
- bra.s lbC0000CE
- lbC0000AE
- bclr D0,0(A0,D1.W)
- cmpi.w #12,D1
- bne.s lbC0000CE
- bclr D0,$135(A6)
- bra.s lbC0000CE
- lbW0000BE
- dc.w $80,$E0,$E0,$F0,$804,$7C,0,0
- lbC0000CE
- move.w D2,D1
- andi.w #$7F,D1
- move.w D1,D0
- andi.w #7,D0
- lsr.w #3,D1
- lea lbW0000BE(PC),A0
- btst D0,0(A0,D1.W)
- beq.s lbC0000EA
- ori.w #$100,D4
- lbC0000EA
- move.w $72(A6),D1
- move.w D1,D0
- addq.w #4,D0
- andi.w #$7F,D0
- cmp.w $70(A6),D0
- bne.s lbC000108
- move.w D1,D0
- move.w #$7D,D2
- subq.w #4,D1
- andi.w #$7F,D1
- lbC000108
- move.w D2,$74(A6,D1.W)
- or.b $135(A6),D4
- move.w D4,$76(A6,D1.W)
- move.w D0,$72(A6)
- ; btst #0,$3D(A6)
- ; bne.s lbC00012C
- ; movea.l $48(A6),A1
- ; tst.l (A1)
- ; beq.s lbC00012C
- ; bsr.l *-$FFFF0278
- ;lbC00012C
-
- MOVE.B #$1,$BFEE01
-
- ; andi.b #$BF,$BFEE01
-
- lbC00012E
- MOVE.B KBDQUALIFIER+1,d0
- TST.L OSM_SLVTRAINER
- BEQ.S .NOTRAINER
- MOVE.L OSM_SLVTRAINER(PC),A0
- JSR (A0)
- .NOTRAINER
- MOVE.B D0,KBDQUALIFIER+1
- BEQ.S .1
- move.l (_Slave),a0
- CMP.B (ws_keyexit,a0),D0
- BEQ.S .QUIT
- .1
- movem.l (SP)+,D2-D4/A6
- move.l _inputhandler(PC),d0
- bne _InputHandlerPI
- rts
-
- .QUIT PEA TDREASON_OK
- MOVE.L _RESLOAD(PC),-(A7)
- add.l #resload_Abort,(a7)
- rts
-
- ; < D1: keyboard raw code without press/release info
- ; < D2: same thing with press/release info (bit #7)
- ; > KBDQUALIFIER updated
-
- _SetQualifierFlags:
- movem.l D0/D1/A0,-(A7)
-
- sub.b #$60,D1
- bcs.b .exit
- cmp.b #$8,D1
- bcc.b .exit
- lea .qualtable(pc),A0
- move.b (A0,D1.W),D0
-
- btst #7,D2
- bne.b .release
- ; key pressed
-
- or.b D0,KBDQUALIFIER
- bra.b .exit
- .release:
- not.b D0
- and.b D0,KBDQUALIFIER
- .exit
- movem.l (A7)+,A0/D1/D0
- rts
-
- .qualtable:
- dc.b IEQUALIFIER_LSHIFT,IEQUALIFIER_RSHIFT,IEQUALIFIER_CAPSLOCK
- dc.b IEQUALIFIER_CONTROL,IEQUALIFIER_LALT,IEQUALIFIER_RALT
- dc.b IEQUALIFIER_LCOMMAND,IEQUALIFIER_RCOMMAND
-
-
-
- **************************************************************************
-
- include "rawdofmt.s"
-
- **************************************************************************
-
- _GETCC:
- btst.b #AFB_68010,(AttnFlags,A6)
- beq.b .68000
- move CCR,D0
- rts
- .68000
- move SR,D0
- rts
-
- **************************************************************************
- * CIAB.RESOURCE *
- **************************************************************************
-
- CIABINIT move.l _ciabbase,d0
- beq .init
- rts
-
- .init move.l #-_LVOSetICR,d0
- move.l #$34,d1
- lea _ciabname(pc),a0
- bsr _InitStruct
- move.l d0,a0
- move.l d0,_ciabbase
-
- patch _LVOAddICRVector(a0),CIABADDICRV
- patch _LVORemICRVector(a0),CIABREMICRV
- patch _LVOAbleICR(a0),_ABLEICR
- patch _LVOSetICR(a0),_SETICR
-
- move.l #$BFD000,34(a0) ; cia base v1.15
- clr.l 40(A0) ; JOTD v1.15
- MOVE.B #CIAB_INT_VAL,41(A0)
- MOVE.W #INTF_EXTER,38(A0)
-
- clr.l (a0)+
- clr.l (a0)+
- clr.l (a0)+
- clr.l (a0)+
- clr.l (a0)
-
- ;; MOVE.B #CIA_COUNTER_INIT,$BFD500
- MOVE.B #CIA_COUNTER_INIT,$BFD700
-
-
- rts
-
-
- ; PutMsg, added by JOTD, implementation: AROS
- ; < A0: MsgPort
- ; < A1: Message
-
- _PutMsg:
- DISABLE
-
- ; Set the node type to NT_MESSAGE == sent message
-
- move.b #NT_MESSAGE,(LN_TYPE,A1)
-
- ; Add it to the message list.
-
- movem.l A0/A1,-(A7)
- lea (MP_MSGLIST,A0),A0
- bsr _ADDTAIL
- movem.l (A7)+,A0/A1
-
- move.l (MP_SIGTASK,A0),D0
- beq.b .notask
-
- ; And trigger the action
- ;; bsr EnterDebugger
- .notask
- ENABLE
- rts
-
- ; GetMsg, added by JOTD, implementation: AROS
- ; < A0: MsgPort
- ; > D0: Message
-
- _GetMsg:
- DISABLE
- lea (MP_MSGLIST,A0),A0
- bsr _REMHEAD ; extracts and remove message from message port
- ENABLE
- rts
-
- ; ReplyMsg, added by JOTD, implementation: AROS
- ; 1> Places "NT_REPLYMSG" into LN_TYPE
- ; 2> Puts the message to the port specified by MN_REPLYPORT
- ; If there is no replyport, sets LN_TYPE to "NT_FREEMSG"
- ; < A1: Message
-
- _ReplyMsg
- DISABLE
- move.l (MN_REPLYPORT,A1),A0 ; check reply port
- cmp.l #0,A0
- bne.b .reply
- ; free message
-
- move.b #NT_FREEMSG,(LN_TYPE,A1)
- bra .exit
-
- .reply
- ; Mark the message as replied
-
- move.b #NT_REPLYMSG,(LN_TYPE,A1)
- ; Add it to the replyport's list
-
- movem.l A0/A1,-(A7)
- lea (MP_MSGLIST,A0),A0 ; reply port
- bsr _ADDTAIL
- movem.l (A7)+,A0/A1
-
- move.l (MP_SIGTASK,A0),D0
- beq.b .notask
-
- ; And trigger the action
- ;; bsr EnterDebugger
- .notask
- .exit
- ENABLE
- rts
-
- ; AddPort, AROS implementation + protection against NULL message list
- ; < A1: port address to add
-
- _AddPort:
- ; Yes, this is a messageport
-
- move.b #NT_MSGPORT,(LN_TYPE,A1)
-
-
- IFEQ 1
- ; Clear the list of messages
-
- move.l (MP_MSGLIST,A1),A0 ; A0 = message list
-
- cmp.l #0,A0
- beq.b .nomsglist
-
- movem.l A0/A1,-(A7)
-
- lea (LH_TAIL,A0),A1
- move.l A1,(LH_HEAD,A0)
-
- clr.l (LH_TAIL,A0)
-
- lea (LH_HEAD,A0),A1
- move.l A1,(LH_TAILPRED,A0)
-
- movem.l (A7)+,A0/A1
-
-
- .nomsglist
- ENDC
-
- ; Arbitrate for the list of messageports
- ; And add the actual port
-
-
- JSRLIB Forbid
- lea (PortList,A6),A0 ; system port list
- JSRLIB Enqueue
-
- JSRLIB Permit
- rts
-
- ; WaitPort
- ; < A0: port
- ; > D0:
- _WaitPort:
- lea (MP_MSGLIST,A0),A1 ; &port->mp_MsgList
- .wait
- cmp.l (LH_TAILPRED,A1),A1 ; while empty, loop
- bne.b .wait ; active loop ATM, no multitasking
-
- ; Return the first node in the list (may return NULL)
-
- move.l (LH_HEAD,A1),D0
- rts
-
- ; RemPort, AROS implementation
- ; < A1: port address to remove
-
- _RemPort:
- JSRLIB Forbid
- JSRLIB Remove
- JSRLIB Permit
- rts
-
-
- _Debug:
- bsr EnterDebugger
- EMUFAIL _LVODebug,_execname
-
-
- EGSINIT:
- ; cannot open egs.library (Tower Assault)
- moveq.l #0,D0
- RTS
-
-
- ForeignAllocMem:
- move.l A6,-(A7)
- move.l $4.W,A6
- ;;; bset #MEMB_CLEAR,D1 ; forces clear for internal OSEmu calls
- JSRLIB AllocMem
- move.l (A7)+,A6
- RTS
-
- ForeignFreeMem:
- move.l A6,-(A7)
- move.l $4.W,A6
- JSRLIB FreeMem
- move.l (A7)+,A6
- RTS
-
-
- AckKeyboard:
- movem.l D0/D1,-(A7)
- BSET #$06,$BFEE01
- MOVEQ.L #2,D0
- .4
- MOVE.B $DFF006,D1
- .3 CMP.B $DFF006,D1
- BEQ.S .3
- DBF D0,.4
- BCLR #$06,$BFEE01
-
- ;; move.w #0008,intreq+$DFF000 ; acknowledge interrupt
-
- movem.l (A7)+,D0/D1
- rts
-
- **************************************************************************
- **************************************************************************
-
- INCLUDE resources.s
- INCLUDE dos.s
- INCLUDE freeanim.s
- INCLUDE nonvolatile.s
- INCLUDE graphics.s
- INCLUDE intuition.s
- INCLUDE lowlevel.s
- INCLUDE diskfont.s
-
- INCLUDE utility.s
- INCLUDE keymap.s
- INCLUDE timer.s
- INCLUDE console.s
- INCLUDE locale.s
-
- INCLUDE mathffp.s
- IFD BIG_OSEMU ; rather untested stuff there
- INCLUDE mathtrans.s
- ENDC
-
- **************************************************************************
- **************************************************************************
- * CHIPMEMORYTABLE AND MEMORY MANAGEMENT DATA *
- **************************************************************************
-
- ;THIS HAS TO BE ABSOLUTELY THE LAST LABEL, THE TABLE HAS A LEN DEPENDING
- ; FROM THE SIZE OF THE MEMORY
- DC.B 'OSEMUEND'
- CNOP 0,8
- _osemu_end
- ALLOCMTAB
-
-